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?
  1. Is there anything similar to python dictionary: {'name1': tag1, 'name2': tag2, .... 'nameN': tagN}
  2. Or should it be stored in a table with two columns - name and tag
Thanks

댓글 수: 3

Stephen23
Stephen23 2020년 1월 31일
What size and class does the tag have? If they are numerics of the same size, then put them into one numeric array, as this will make your data processing simpler. A table would likely be the best choice for what you described so far.
What about simple char?
data= ['name1: tag1'
'name2: tag2'
'nameN: tagN']
Alisher Narzulloev
Alisher Narzulloev 2020년 1월 31일
Tag is one string value. I also believe table is the best approach. Thanks.

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2020년 1월 31일

1 개 추천

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

카테고리

도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

릴리스

R2017b

질문:

2020년 1월 31일

댓글:

2020년 1월 31일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by