Answered
Comparing updated array from two consecutive iterations
Use a while loop that is sure to make at least two trips through. old = all NaNs so as to surely fail 1st test b = fa...

9 years ago | 1

Answered
sortrows(data, [2,1]) is doing the 2nd round of sorting incorrectly in MATLAB R2017a
I would hazard the guess that in spite of their appearance using “format short” as you clearly have, the values in the second co...

9 years ago | 1

Answered
How to define random points above and below a define line within a specific range
Let w be the allowed perpendicular distance of random points on either side of the line segment. Let x1 be the x-coordinate of ...

9 years ago | 1

Answered
How to remove an specific array from matrix
[m,n] = size(A); for k = 1:m a = A(k,A(k,:)~=100); A(k,:) = [a,zeros(1,n-length(a))]; end

9 years ago | 1

Answered
Creating a parameter which indicates adding values to only part of the elements in a Matrix?
p = 1:round(alpha*size(OldMatrix,1)); NewMatrix(p,:) = OldMatrix(p,:)+data;

9 years ago | 0

Answered
How do I replace trapz with sum?
In place of “SY_comp=trapz(xy(1:M,1),xy(1:M,2))” you could write: SY_comp=1/2*sum(diff(xy(:,1)).*(xy(1:M-1,2)+xy*(2:M,2)));...

9 years ago | 0

| accepted

Answered
How can Fix the "find" with for loop
In your code you are assuming that the ‘find’ operation will always find an index from X that will match one in xe. The trouble...

9 years ago | 0

Answered
while loop doesn't produce correct result
You have not placed the line "C = (2/(pi*(1-4*n^2)))^2;" inside the 'while' loop where it could be updated with changing values ...

9 years ago | 1

| accepted

Answered
How do I change the orientation of a marker randomly?
If you mean random orientation with respect to the cartesian coordinate origin, and if the orientation change is to be the same ...

9 years ago | 0

Answered
My script won't run (error) how do I fix it?
The error message probably occurs when your vector ‘vec’ does not contain the value ‘targetVal’. In that case you repeatedly ei...

9 years ago | 0

Answered
How can I solve this integral equation?
I would suggest utilizing a little calculus here: integral of a+b*T+c*T^2 w.r. T from T = T1 to T = T2 is equal to: ...

9 years ago | 1

Answered
How to pre-allocate an empty matrix ?
Rather than stacking your ‘appnd_data’ successively by: for m = 1:length(s.labs) ...

9 years ago | 1

Answered
How to obtain n smallest values in a 3-dimensional Matrix for each step in the 3rd dimension?
Let A be the original 3D array. [k,l,m] = size(A); A2 = reshape(A,[],m); N = zeros(n,2,m); for im = 1:m ...

9 years ago | 1

| accepted

Answered
How to sum up in matrix
N = [S,zeros(size(S,1),2)]; N(1,3) = 240; t = 240; for k = 2:size(S,1); if N(k,1)~=N(k-1,1) N(k,3) ...

9 years ago | 0

Answered
could you write integral matlab code
This is a problem in calculus. The indefinite integral would be: 1/8*(sin(2*t)-cos(2*t)-2)*exp(-2*t) + C Note that this...

9 years ago | 1

| accepted

Answered
How to print out the exact value for a variable in the workspace?
If you want the value expressed in decimal form, in the great majority of cases these cannot be given exactly, since all our com...

9 years ago | 0

Answered
Building vector with for- and if statements
Make two changes: k = 0; c = 1:1:30; for i=1:30 if mod(30,c(i))==0 k = k+1; v(k) = c(i); end...

9 years ago | 0

Answered
i have a important question!! ( function "randfixedsum" )
I think you might prefer to use the following code rather than using randfixedsum and rounding to integers: function R = r...

9 years ago | 1

Answered
Differentiating a symbolic function
Express your function in symbolic form and use ‘diff’.

9 years ago | 0

Answered
HOW TO USE RANDOM and Cross paired?
Use my randfixedsum in the File Exchange at: http://www.mathworks.com/matlabcentral/fileexchange/9700-random-vectors-with-f...

9 years ago | 0

Answered
How to create a while loop that can determine how many years do you have to invest $100000 at a compound interest of 5% per year to double your money?
Who needs a loop to do this trivial problem? We want to solve for n in the equation 100000*(1.05)^n = 200000 Rewrite i...

9 years ago | 0

Answered
does matlab have a problem with modular integer arithmetic?
As has so often been pointed out in this forum, matlab’s “double” in everyone’s computers possesses a significand (mantissa) con...

9 years ago | 0

Answered
How to change a formula so that it does element by element multiplication?
The purpose of the dot is to enable matlab to distinguish between different kinds of operations between elements of arrays, for ...

9 years ago | 0

Answered
Parse Error at '>' Issue
Also you cannot use the short-circuit && on vectors, only on scalars.

9 years ago | 0

Answered
Choose random between two option.
There should be no need to go through such a simulation. For each birth the probability that a boy is born is one-half regardle...

9 years ago | 0

Answered
Make a numerical iteration using while loop
You need to place the computation of T_tc inside the while loop. As it stands, there will be no change to Tb after the first tr...

9 years ago | 0

Answered
How to replicate a matlab procedure
@Andrew. You state that you are doing a Monte Carlo simulation. That is perhaps the reason why you have been unable to duplica...

9 years ago | 0

Load more