Beantwortet
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...

fast 9 Jahre vor | 1

Beantwortet
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...

fast 9 Jahre vor | 1

Beantwortet
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 ...

fast 9 Jahre vor | 1

Beantwortet
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

fast 9 Jahre vor | 1

Beantwortet
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;

fast 9 Jahre vor | 0

Beantwortet
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)));...

fast 9 Jahre vor | 0

| akzeptiert

Beantwortet
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...

fast 9 Jahre vor | 0

Beantwortet
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 ...

fast 9 Jahre vor | 1

| akzeptiert

Beantwortet
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 ...

fast 9 Jahre vor | 0

Beantwortet
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...

fast 9 Jahre vor | 0

Beantwortet
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: ...

fast 9 Jahre vor | 1

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

fast 9 Jahre vor | 1

Beantwortet
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 ...

fast 9 Jahre vor | 1

| akzeptiert

Beantwortet
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) ...

fast 9 Jahre vor | 0

Beantwortet
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...

fast 9 Jahre vor | 1

| akzeptiert

Beantwortet
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...

fast 9 Jahre vor | 0

Beantwortet
how to find a mean for a set of values in a given data. ive got a data with 60000 values and i wanted to find mean for group of 1000 values so that i can get 60 mean values so how can i do that using loop function please help me?
Assume 'data' is an array with your 60000 values. m = mean(reshape(data,1000,[]),1); This will give you a row vector of ...

fast 9 Jahre vor | 0

Beantwortet
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...

fast 9 Jahre vor | 0

Beantwortet
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...

fast 9 Jahre vor | 1

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

fast 9 Jahre vor | 0

Beantwortet
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...

fast 9 Jahre vor | 0

Beantwortet
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...

fast 9 Jahre vor | 0

Beantwortet
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...

fast 9 Jahre vor | 0

Beantwortet
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 ...

fast 9 Jahre vor | 0

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

fast 9 Jahre vor | 0

Beantwortet
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...

fast 9 Jahre vor | 0

Beantwortet
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...

fast 9 Jahre vor | 0

Beantwortet
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...

fast 9 Jahre vor | 0

Mehr laden