accessing cell data using brace indexing,
조회 수: 7 (최근 30일)
이전 댓글 표시
Hi everyone,
I am tring to access the content of multiple cell in a loop. I have used the code:
for k = 1:length(predictors)
usg = predictors{k};
end
But it doesn't work. Instead I'm getting error that reads: Brace indexing not supported for this variable type. Could someone help please?
답변 (3개)
Catalytic
2020년 1월 28일
You need to check what predictors really is. It is not a cell array, as you believe.
댓글 수: 0
Image Analyst
2020년 1월 28일
The error is saying it's not a cell array like you think. It's something else, like a double or something. Where did it come from? Did some other function create it? If so, what?
댓글 수: 0
Abdul Rof V
2021년 8월 29일
편집: Abdul Rof V
2021년 8월 29일
PI=ones(10,10);
p0=0;
for i=1:5
p{i}=PI{i}
end
anything wrong in indexing
댓글 수: 1
Walter Roberson
2021년 8월 29일
You cannot use {} indexing with numeric arrays such as PI is assigned. {} indexing is reserved for container datatypes such as cell arrays or tables or strings.
You need () indexing for numeric datatypes.
Note: your PI is 2 dimensional, but you are using a single index for it. That does have meaning and can be valid, but please make sure it is what you want to do.
참고 항목
카테고리
Help Center 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!