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

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 Steven Lord Posts: 18,038 Registered: 12/7/04
Re: Saving matrix each iteration
Posted: Sep 20, 2013 10:35 AM
 Plain Text Reply

"Sincloe Brans" <dickson.f1@gmail.com> wrote in message
news:l1gh88\$75a\$1@newscl01ah.mathworks.com...
> Hi Steve, Thanks for the recommendation. The reason I want to convert them
> to individual matrices is because I need to calculate the maximum of each
> row at later stage.
> Right now I use,
> [maxValue, rowIdx] = max(C(:,end),[],1); %max value and the row index
> to determine the maximum of C=min(A,[],2); How do I do this for each
> B{1}... B{j}

C = cell(1, 10);
for k = 1:10
C{k} = magic(k+2);
end
maxRows = cell(1, 10);
for k = 1:10
maxRows{k} = max(C{k}, [], 2);
end

Since each matrix stored in C has a different number of rows, it doesn't
make sense to try to combine all the row maximum vectors into one matrix so
I used a second cell array. If they did, you could make maxRows a regular
matrix.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
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

© The Math Forum at NCTM 1994-2018. All Rights Reserved.