How can I use squeeze to extract a 2D matrix with each point (x,y) having 3 items a,b,c?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Matt J
le 24 Avr 2016
Modifié(e) : Matt J
le 24 Avr 2016
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);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!