Answered
Why do i keep getting this," Incorrect use of '=' operator." error?
This is not valid MATLAB syntax: for m=1:M & n=0:N Maybe you wanted nested for loops? for m=1:M for n=0:N z = z+...

6 years ago | 0

| accepted

Answered
Add Consecutive Numbers sent to a Matrix in a Matlab Function
Sounds like maybe you want persistent variable behavior. E.g., function travel_dist = DeltaDistance(x) persistent y if( isemp...

6 years ago | 0

| accepted

Answered
Recursive definition of anonymous function
@(x) STUFF Takes a snapshot of all of the workspace variables used in STUFF in order to create the function handle. It doesn't...

6 years ago | 1

| accepted

Answered
help PLease, RK4!
You left out some * operators on the k2 and k3. This fy = @(time,x1,x2,x3) m2*x2+c3*(x2-x3)+c2*(x2-x1)+k3*(x2-x3)+k2(x2-x1); f...

6 years ago | 1

Answered
OpenMP in mex file only produces 1 thread
What if you try to force it? E.g., #pragma omp parallel num_threads(omp_get_max_threads()) Or maybe omp_set_num_threads(omp_...

6 years ago | 1

| accepted

Answered
if x=0
x = input('x value: '); y = input('y value: '); k = x * y; if k == 6 % <-- Use == for equality test k1 = 2; elseif k ...

6 years ago | 0

| accepted

Answered
Performing calculations on a vector
The log10( ) function is vectorized, so just this result = 20 * log10(4*pi*d./lambda);

6 years ago | 0

| accepted

Answered
Rename Matrix in Using String
Suppose you could somehow rename your variable to the name contained in filename. What would you do next? How would you access...

6 years ago | 0

Answered
Scalar max of cell array with structure
If you reshape the input first, a one-liner version of your code: peak = max(cellfun(@(x) max(abs(x.noise(:))),myCell(:))); ...

6 years ago | 0

| accepted

Answered
Sum of sequence with accuracy
exp(-x) will calculate that sum.

6 years ago | 1

Answered
Need help solving this problem with newtons method
To match how you are calling it, you need to switch the order of the arguments in this function handle: F = @(p, t) k*p*(L-p)-a...

6 years ago | 0

Answered
Operators "concatenation" ?
No. MATLAB syntax does not allow using ( ) or { } right after a function call. You could of course create a third function to d...

6 years ago | 0

| accepted

Answered
Time of sparse matrix components allocation
Every time you add even one element to a sparse matrix, it has to copy data ... perhaps all of the current data ... to make room...

6 years ago | 0

Answered
How to get matrix data from function ,anyone help me
Not sure what the real question is. Maybe this does what you want? function [apZ,atZ]=example(a,Z) apZ = a + Z;...

6 years ago | 0

| accepted

Answered
Order a string row based on another string row by matching each element (like the sort function does)
One way: [~,idxb] = sort(B1); [~,idxa] = sort(idxb); A1new = A1(idxa); A2new = A2(idxa);

6 years ago | 0

Answered
How to get multiple roots of x
How are you solving it now? Maybe you just need to feed your method different starting guesses.

6 years ago | 0

Answered
Future Bank Account Balance
This line overwrites your old balance vector with a scalar oldbalance = newbalance(i); Instead of keeping track of old balance...

6 years ago | 0

| accepted

Answered
How to compare elements with above and below element in a column?
Is this what you want? for T = 2:M if( abs(A(T,4) - A(T-1,4)) > 50 ) A(T,4) = 0; end end

6 years ago | 0

| accepted

Answered
How do I single out elements in a vector?
Hints: You might look at the mod( ) or rem( ) function to determine if values are even. To determine how many are even, you cou...

6 years ago | 0

Answered
Matlab crashes while running MEX Fortran 90 routine
Three comments: 1) You should NEVER, NEVER, NEVER pass literal integers into mex API functions. It can often be the case that ...

6 years ago | 0

| accepted

Answered
Troubles with data types: integers, doubles, scientific notation, and type casting
You are confusing integer "types" with integer "values". Integer types are int8, uint8, ... int16, uint64. Integer values a 1,...

6 years ago | 0

Answered
Error using * Inner matrix dimensions must agree.
Use element-wise operators (with the dot .) instead of matrix operators (without the dot .), e.g., x1= 1 - (exp(-(t/4))).*(cos(...

6 years ago | 0

| accepted

Answered
Cant Use Reshape Function with Randi or Randperm
I'm guessing you need to tell this dec2bin call that it always needs to produce 16 digits also: permboxin_temp = dec2bin(permbo...

6 years ago | 0

Answered
Using for loop to match generated random numbers to an input value
Since you don't know ahead of time how many tries it will take, this is best done with a while loop instead of a for loop. E.g.,...

6 years ago | 0

| accepted

Answered
How can I append a new cell onto the end of a Cell Array?
If F really is a cell array in the format you list, then just C(end+1) = F; If not, then you may have to do this: C(end+1) = ...

6 years ago | 0

| accepted

Answered
Nonscalar arrays of function handles are not allowed; use cell arrays instead.
You don't need to create an array of function handles. You just need to construct one function handle to use for that iteration....

6 years ago | 0

| accepted

Answered
Forward Euler method for Higher order differential equation
You need to think of Y as your three element column vector as you have defined. So at each step you are dealing with a column v...

6 years ago | 1

| accepted

Answered
Subscript indices must either be real positive integers or logicals while k starts from 1 .
The RK4( ) function expects to call the derivative function with the signature F(tt,y), i.e. time is the 1st argument. But your...

6 years ago | 1

Answered
My matrix should be symmetric but isn't by a ridiculous margin
Welcome to the world of floating point arithmetic. This is typical and not unusual behavior. https://www.mathworks.com/matlabc...

6 years ago | 0

| accepted

Answered
Plot a 100x100 grid of 1's and 0's
Another option: b = your binary matrix spy(b);

6 years ago | 0

Load more