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!