Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Saving matrix each iteration
Replies: 5   Last Post: Sep 20, 2013 10:35 AM

 Messages: [ Previous | Next ]
 Steven Lord Posts: 18,038 Registered: 12/7/04
Re: Saving matrix each iteration
Posted: Sep 18, 2013 9:32 AM

"Sincloe Brans" <dickson.f1@gmail.com> wrote in message
news:l1bgqf\$puf\$1@newscl01ah.mathworks.com...
> So I have two matrix A which keeps changing every iteration. I do 10
> iterations and so I get 10 A's. Each A is increased by one row at the end
> of each iteration. I also have an external loop k=50,100,150. For each k I
> generate 10 matrix. So in this case I generate totally 30 matrix. My
> question is how do I save them so that I can use it for future
> calculation.
>
> k=1
> while k<=150
> B = cell(10,1);
> For i=1:10
> A(end+1,:) = M(rowIdx,:)
> B{c} = A;
> c=c+1
> end
> k=k+50
> end
>
> This will save only 10 matrix created for each k. Is there any way I can
> generate B{c}{k} kind of matrix?

Do you want to create a cell array whose cells themselves contain a cell
array, or do you just want a 2-D cell array? If the latter:

Y = cell(10, 20);
for row = 1:10
for col = 1:20
Y{row, col} = magic(row+col);
end
end

--
Steve Lord
slord@mathworks.com
http://www.mathworks.com

Date Subject Author
9/18/13 John Dickson
9/18/13 Steven Lord
9/19/13 John Dickson
9/19/13 Steven Lord
9/20/13 John Dickson
9/20/13 Steven Lord