Reputation: 101
In my program i have got the value of
RpMats{k} = Rp;
Where RpMats is an array of matrices and each element of RpMats is 50x50 matrix. Example: RpMats = [(50x50 matrix) (50x50 matrix) (50x50 matrix) (50x50 matrix) .... (50x50 matrix)] I have total 100 matrices in RpMats. I want to use these elements of RpMats (which are matrix) in the below loop:
for j = 1 : 50
X = max( Rp(j,:)-RecPackets, 0) ;
end
% here Rp is the input of first element of RpMats, then second element of RpMats like this. Which means by mentioning Rp i want to provide input from the RpMats. first input of Rp will be the first matrix of RpMats Like this i want to give all the 100 matrix of RpMats as input to Rp. Is it possible?
Upvotes: 0
Views: 136
Reputation: 25232
Basically you need two indices. One to specify which matrix of your array you want to adress, lets call that index jj
. And further the index which adresses the element of each matrix, e.g. ii
.
Then you can create (for example) a nested loop:
for jj=1:number of matrices in array
for ii=1:50
Rp{jj}(ii,:) = do something
end
end
So cell arrays (what your matrix array is) are adressed with {...}
returning a matrix of doubles and this matrix is then adressed with (...)
.
If you want to use something like Rp{jj,:} - I'd recommend {Rp{jj,:}}
(for example when you have a matrix of matrices but you're just interested in a certain column, you could filter it like that.
Upvotes: 2