Thursday, 15 May 2014

matlab - In an assignment A(I) = B, the number of elements in B and I must be the same -


Now, I understand the problem here, what I do not understand is how should I get started ?

For example, in my case, an array is generated at the end of each for loop in 'P', which is programmed to run 101 times, the output of P looks like this

p =

-0.0149 -0.0149 Now, I want to store this value in a different variable at the end of each for loop and I want to increase its index. .

So, what should be the dimension of that variable?

I have tried to start -> & gt; A = RAND (2,101);

If you do not want to pre-assign the array A, then after you for the loop erasurement You can add values ​​to each A in each:

  A = []; To get the loop pa vector (every move should be 2x1) A = [AP]; End   

or you can write directly in the loop:

  A (:, i) = p; % But your P-vector does not look like 1x2 and 2x1 if it's 2x1, then you should start one as a rand (101,2)    

No comments:

Post a Comment