How can I use squeeze to extract a 2D matrix with each point (x,y) having 3 items a,b,c?
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone, I need your assistance regard using squeeze to extract 2D matrix data. I will like to extract individually the value of w=1,2,3 OR at least all w together. Will really appreciate your assistance. Something like:
for v = 1:v_final
for m = 1:m_final
for k = 1:3
w1=myval{v,m}(:,:,1);
w2=myval{v,m}(:,:,2);
w3=myval{v,m}(:,:,3);
end
end
end
0 个评论
采纳的回答
Matt J
2016-4-24
编辑:Matt J
2016-4-24
I'm not sure why squeeze() would be involved and, since you already have a posted solution, I'm not sure what's different between that and what you're actually looking for. However, if all arrays myval{v,m} are the same size MxNx3, I would consolidate them into a 5-D array.
W=cat(4, myval{:});
W=reshape(W,[M,N,3, v_final, m_final];
W=permute(W,[4,5,3,1,2]);
In this form, one can lookup complete arrays of size v_final x m_final or of size v_final x m_final x 3 by doing things like;
w1=W(:,:,1,x,y);
w2=W(:,:,2,x,y);
w3=W(:,:,3,x,y);
wij=W(:,:,1:3,x,y);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Algebra 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!