-2

i have an array of multiple rows and 5 columns(fixed) , i need to save values dynamically(in loop) I did this thing.

for i from 1 to n do
    A(i,:)=[var1 var2 var3 var4 var5]
end_for

But it gives error. Anyone who knows the solution, Please help me.. Thank you!

user2870778
  • 107
  • 2
  • 13

1 Answers1

3

Your code example is not Matlab.

What the error you got means is that the size of A(counter,:) (the variable into which you try to assign new values) does not match the size of [var1 var2 var3 var4 var5].

Use debug mode, put a breakpoint at the problematic line and check what is size( A(counter,:) ) and what is size([var1 var2 var3 var4 var5]) then fix your code so that these two sizes would actually match.

Good luck!

PS,
It is best not to use i as a variable name in Matlab.

Community
  • 1
  • 1
Shai
  • 111,146
  • 38
  • 238
  • 371