How to merge similar matrixes and list them on columns.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi Matlab users,
OK, so I have a 238x132 matrix representing current movements in one day(let's call it U), and two 238x132 matrixes representing one Latitude and one Longitude (they are like this because they are gridded). What I need to do is to put all three of them on columns like this: Latitude Longitude U where Latitude and Longitude have the same positions inside their matrixes as U.
I can do it like this: U11=[Latitude(1,1) Longitude(1,1) U1(1,1)]; but it takes a lot of time. Is there a easier way?
I am really ashamed for not knowing this.
0 Commenti
Risposta accettata
Andrei Bobrov
il 9 Set 2013
Modificato: Andrei Bobrov
il 9 Set 2013
Umn = [Latitude(:) Longitude(:) U(:)];
other variant
M = cat(3,Latitude,Longitude,U);
C = cellfun(@(x)x(:)',num2cell(M,3),'un',0);
out = cell2mat(C);
more variant
M = cat(3,Latitude,Longitude,U);
out = reshape(permute(M,[3 2 1]),[],size(U,1))';
or
M = [Latitude(:),Longitude(:),U(:)];
out = reshape(permute(reshape(M',3,size(U,1),[]),[2 1 3]),size(U,1),[]);
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Descriptive Statistics 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!