Assign Cell Array to singe variable
이전 댓글 표시
For a cell array or length n. I want to assign each cell to variables named A1, A2, etc with a loop. For example:
>> whos d
Name Size Bytes Class Attributes
d 1x3 39720 cell
>> [A1 A2 A3] = d{1:end};

I would like to do this with a loop to accomadate a cell array of any length.
Thanks
채택된 답변
추가 답변 (1개)
Azzi Abdelmalek
2016년 7월 30일
편집: Azzi Abdelmalek
2016년 7월 30일
This is not recommended. Read this http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F
d={1 2 3}
Why do you want to create A1, A2 and A3 when you can access to any value in d?
d{1}
d{2}
d{3}
댓글 수: 2
Zekeftw
2016년 7월 31일
"I couldnt find a way to do this with cell arrays"
Loop over the cell array, perform the calculation. Read this:
카테고리
도움말 센터 및 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!
