How to merge similar matrixes and list them on columns.
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Andrei Bobrov
2013-9-9
编辑:Andrei Bobrov
2013-9-9
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),[]);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Descriptive Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!