how to store more than one list into one list or one file to be includes all generated list from a loop ????

1 view (last 30 days)
hello every body...
i try to store generated lists in one list
here is the code:
Ylst=[];
for i=3
Y=[1*i;2;3];
Ylst(i)=Y;
end
this is the error:
In an assignment A(I) = B, the number of elements in B and I must be the same.
Can any body help to correct it please.. how to do it??
thanx in advence...

Accepted Answer

Walter Roberson
Walter Roberson on 19 Jun 2015
Ylst={};
for i=3
Y=[1*i;2;3];
Ylst{i}=Y;
end
However as you are using fixed length lists you should consider using a 2D array:
Ylst=[];
for i=3
Y=[1*i;2;3];
Ylst(:,i)=Y;
end
  2 Comments
Jack
Jack on 19 Jun 2015
Thank you so muck for your answer, it works but not give me the results i want.
you can see the the list of Y is changed in each and every loop but the result only give me the value of Y in last loop.
how to solve it
0 0 3
0 0 2
0 0 3
i want to see result as in the following :
1 2 3
2 2 2
3 3 3
patient please ...

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!