arranging a matrix
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (2)
Thomas
il 15 Mag 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 Commenti
Jan
il 15 Mag 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 Commenti
Vedere anche
Categorie
Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!