Error: Unable to perform assignment because brace indexing is not supported for variables of this type
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Riccardo Rossi
am 31 Jan. 2019
Kommentiert: Stephen23
am 29 Okt. 2022
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!
2 Kommentare
madhan ravi
am 31 Jan. 2019
Bearbeitet: madhan ravi
am 31 Jan. 2019
STRGT=cell(1,nRow); % before loop , also move STRAIGHT outside the loop
[comment moved to answer section]
Akzeptierte Antwort
madhan ravi
am 31 Jan. 2019
STRGT=cell(1,nRow); % before the loop ,also move STRAIGHT outside the loop
2 Kommentare
Muhammad Usman Saleem
am 29 Okt. 2022
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
am 29 Okt. 2022
"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:
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!