How to convert struct filed to cell array before R2016a?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Mr M.
il 11 Ago 2016
Risposto: Sindhuja Parimalarangan
il 12 Ago 2016
How to convert struct filed to cell array before R2016a? I want to convert mystruct(:).name to {'name1','name2','name3'}, where mystruct(1).name = 'name1', etc.
0 Commenti
Risposta accettata
Sindhuja Parimalarangan
il 12 Ago 2016
Hi
For example, if you had a struct with 3 fields as follows:
>>s(1).category = 'tree1';s(1).height = 37.4; s(1).name = 'birch1';
>>s(2).category = 'tree2';s(2).height = 37.5; s(2).name = 'birch2';
To convert the 'name' fields into a cell array A,
>>A = {S(:).name}
In your case, it would be:
>> myCell = {mystruct(:).name}
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Structures in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!