arranging a matrix
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have to create a matrix of dimension 240*7. I got one submatrix of 2*7 which is in a loop. there are 120 iteration for each time I got the 2*7 matrix. from these 2*7 matrices I want to create a 240*7 matrix. I don't know How to do it.how to arrange them. Now I need to combine these matrices into one large matrix; how do I do that? please help me.
0 commentaires
Réponses (2)
Thomas
le 15 Mai 2012
Perhaps you need something like this..
c=[];
for ii=1:120
a=rand(2,7); %generate 2x7 matrix every loop
c=[c;a]; % every loop concatenates new 'a' to current output
end
size(c)
0 commentaires
Jan
le 15 Mai 2012
A pre-allocation is important:
c = zeros(240, 7);
for ii = 1:2:240
a = rand(2,7);
c(ii:ii+1, :) = a;
end
An similar approach:
c = zeros(120, 2, 7);
for ii = 1:120
a = rand(2,7);
c(:, ii, :) = a;
end
c = reshape(c, 240, 7);
0 commentaires
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!