Extract fields from structure
Mostra commenti meno recenti
Hello,
I have a structure A that includes 2 structures, B and C. I want to extract from structure "C" , to the workspace, specific fields that start with certain set of letter, i.e I want to extract fields that start wih XX_YY.
I did
S=[A.C(:)]; save('param.mat','-struct','S');
But the file takes forever to load to the workspace.
Thanks in Advance!
3 Commenti
Dyuman Joshi
il 14 Ago 2022
Is it necessary to save the file? (Might be for any computation after the extraction, I presume)
Samy Alkhayat
il 15 Ago 2022
Dyuman Joshi
il 15 Ago 2022
It is, as the answers below show
Risposta accettata
Più risposte (1)
S.C.XX_YY1=5;
S.C.XX_YY2=10;
S.C.ZZ=3;
f=fieldnames(S.C);
I=startsWith(f,'XX_YY');
f=string(f(I));
for fI=string(f(I))'
Extraction.(fI)=S.C.(fI);
end
Extraction
1 Commento
Samy Alkhayat
il 15 Ago 2022
Categorie
Scopri di più su Structures in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!