How to reshape/transform matrices with 3D data?
2 次查看(过去 30 天)
显示 更早的评论
Hello!
I would like to reshape/transform matrices with 3D data (see attached photo). Is there an existing method for this?
Thank you
- - - - - - - - - - - - - - -
Edit:
Initial situation:
X=[1;2;3]; Y=[1,2,3]; Z=[1,2,3;4,5,6;7,8,9];
Target:
X=[1;1;1;2;2;2;3;3;3]; Y=[1;2;3;1;2;3;1;2;3]; Z=[1;2;3;4;5;6;7;8;9];
3 个评论
采纳的回答
James Tursa
2017-7-6
[y,x] = ndgrid(Y,X);
x = x(:);
y = y(:);
z = reshape(Z',[],1);
3 个评论
Stephen23
2017-7-7
编辑:Stephen23
2017-7-7
@Manuela Gräfe: ndgrid does not require its inputs to have the same number of elements:
>> [Xm,Ym] = ndgrid(1:2,1:9); % no error!
>>
So you have an error but you did not show us the complete error message and you did not show us the code... If you actually want help then you should show us what you tried and the complete error message. Thia means all of the red text.
hanif hamden
2020-11-16
Hi, i would like to ask how to reshape back the data from right to the left of above figure?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!