save each 2 dimensions of 3 dimensions matrix
Afficher commentaires plus anciens
Dears
I have a 5*30*32 matrix and want to save it to five variables in a .mat file. I wonder is there a direct way to replace the following work? Thanks.
a=zeros(5,32,32);
a1=a(1,:,:);
a2=a(2,:,:);
a3=a(3,:,:);
a4=a(4,:,:);
a5=a(5,:,:);
save('a.mat','a1','a2','a3','a4','a5')
Réponses (1)
As Rik says, it's a terribly inadvisable thing to do, however, here is one way you could accomplish it:
s=cell2struct( num2cell(a,[1,2]) ,"a"+(1:size(a,3)),3);
save('a.mat','-struct','s')
2 commentaires
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!