Error: Unable to perform assignment because brace indexing is not supported for variables of this type

조회 수: 1 (최근 30일)
Hi everybody,
if I launch this code using a single POINT it works, if instead I insert it inside a loop (with POINT that change at every iteration) this message error appears to me:
Unable to perform assignment because brace indexing is not supported for variables of this type
POINT=[x,y,z]
nRow = size(A, 1);
for iRow = 1:nRow
STRAIGHT=-20:.01:20;
STRGT{iRow}=repmat(POINT,length(STRAIGHT),1)'+((A(iRow,:))-POINT)'*STRAIGHT;
end
How can i resolve it?
Thank's!

채택된 답변

madhan ravi
madhan ravi 2019년 1월 31일
STRGT=cell(1,nRow); % before the loop ,also move STRAIGHT outside the loop
  댓글 수: 2
Muhammad Usman Saleem
Muhammad Usman Saleem 2022년 10월 29일
Why its necessary to declar an empty cell array before loop?
Why Matlab through this error when we try to declar inside loop? please
Stephen23
Stephen23 2022년 10월 29일
"Why its necessary to declar an empty cell array before loop? "
It is not empty, it has size 1xnRow.
The reason is to preallocate the array before the loop, thus specifying both the size and type of the array:

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

추가 답변 (1개)

KSSV
KSSV 2019년 1월 31일
편집: KSSV 2019년 1월 31일
POINT=[x,y,z] ;
nRow = size(A, 1);
STRGT = cell(nRow,1) ;
for iRow = 1:nRow
STRAIGHT=-20:.01:20;
STRGT{iRow}=repmat(POINT,length(RETTA),1)'+((A(iRow,:))-POINT)'*STRAIGHT;
end

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by