How i can combine three or more than three matrix?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
y=[repmat(x1,size(x2,1),1),repelem(x2,size(x1,1),1)];
I am writing this code for combining two matrix where the row number is different but column is same .
My question is how i can combine more than two matrix where their row number is differnt but column is same ?
0 Commenti
Risposta accettata
Stephen23
il 10 Ago 2021
Modificato: Stephen23
il 10 Ago 2021
Note that you will run out of memory very quickly as you increase the number of matrices.
format compact
inp = {rand(3,4),rand(4,4),rand(5,4)}; % all matrices in one cell array.
celldisp(inp)
fun = @(m)1:size(m,1);
idr = cellfun(fun,inp,'uni',0);
[idr{:}] = ndgrid(idr{:}); % comma-separated lists
baz = @(m,r)m(r(:),:);
tmp = cellfun(baz,inp,idr,'uni',0);
out = horzcat(tmp{:})
0 Commenti
Vedere anche
Categorie
Scopri di più su Logical 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!