필터 지우기
필터 지우기

how to do a for cycle for cell arrays

조회 수: 2 (최근 30일)
Hugo
Hugo 2022년 2월 25일
댓글: Stephen23 2022년 2월 25일
Hello,
i have a cell array that is has 20 cells of 1000*20 tables
I am trying to write the following code:
FA1=data2{1,1}
FA2=data2{1,2}
FA3=data2{1,3}
FA4=data2{1,4}
FA5=data2{1,5}
FA6=data2{1,6}
FA7=data2{1,7}
FA8=data2{1,8}
FA9=data2{1,9}
FA10=data2{1,10}
When I try to transform it into
for i=1:1:10
FA(i)=data2{1,i}
end
I got an error. I would like to know what the way of doing this properly is.
I thank you in advance,
Best regards,
  댓글 수: 1
Stephen23
Stephen23 2022년 2월 25일
"I would like to know what the way of doing this properly is."
The proper way is to use simple and efficient indexing to access the data directly from data2.
Anything else is a waste of time (yours and runtime).

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

채택된 답변

Jan
Jan 2022년 2월 25일
And the next question concering indices hidden in the names of variables.
Use an array instead. In your case, data2 is sufficient already. If you really want to call it FA and want to crop e.g. further elements:
FA = data2(1:10)
FA{1}
FA{2}

추가 답변 (1개)

Image Analyst
Image Analyst 2022년 2월 25일

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by