How to get and 3D matrix from 2 2D matirces?
1 次查看(过去 30 天)
显示 更早的评论
Hi I have 2 structures(of many cells) that plot the 2d coordinates of a particle in XY coordinates and YZ cordinates and I want to create a structre that gives me the 3D coordinate from them by matching the points in at the Y plane? Any idea how to approach this issue?
回答(1 个)
Hiro Yoshino
2022-5-30
How about the following solution using "ismember" ?
% xy - 2D matrix
x = [1 2 3 4 5]';
y1 = [3 2 1 4 5]';
xy = [x,y1]
%yz - 2D matrix
y2 = [1 2 3 4 5]';
z = [10 15 3 4 9]';
yz = [y2,z]
% correspondance:
[idx, loc]=ismember(y1,y2);
% check if y1 and y2(loc) are identical
y1
y2(loc)
% 3D matrix
xyz = [x,y1,z(loc)]
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!