Store values from for loop
2 ビュー (過去 30 日間)
古いコメントを表示
I am looping through files (using for loop) and getting two values from each loop - name and tag. What is the best way to store these values, if I later want to access tags using names?
- Is there anything similar to python dictionary: {'name1': tag1, 'name2': tag2, .... 'nameN': tagN}
- Or should it be stored in a table with two columns - name and tag
Thanks
3 件のコメント
darova
2020 年 1 月 31 日
What about simple char?
data= ['name1: tag1'
'name2: tag2'
'nameN: tagN']
回答 (1 件)
KSSV
2020 年 1 月 31 日
names = cell(N,1) ;
tags = cell(N,1) ;
for i = 1:N % N is number of files
% get names and tages
names{i} = name ;
tags{i} = tag ;
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!