How to loop through structure with words?
1 次查看(过去 30 天)
显示 更早的评论
Hi guys,
I would like to systematically change the name in the loop (from BreakingGlass to WhiteNoise) to work in the 6X9 matrix.
My Idea is to do:
reflectance.nhy1.NAME OF SOUND.(:,:)
I need to do
tones = '1'; The 1 is just an example which works, but I need to do this with
tones = 'BreakingGlass', but then the str2num function gives me a NaN back, how can I solve this problem?
finish_tones = str2num(tones)
How can I fill a new name of sound in each iteration?
Thank you for your help!
采纳的回答
Fangjun Jiang
2021-7-28
编辑:Fangjun Jiang
2021-7-28
fn=fieldnames(reflectance.nhy1);
for k=1:length(fn)
reflectance.nhy1.(fn{k})
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!