Brace indexing is not supported for variables of this type.

조회 수: 1 (최근 30일)
Hello
I have got this error message:
Error in cell2mat (line 36)
if isnumeric(c{1}) || ischar(c{1}) || islogical(c{1}) || isstruct(c{1})
Error in slope_centres (line 248)
C=cell2mat(Csurf{surface,g});
In each loop try, I want to get a specific array of the cell matrix Csurf (its indexing depend on the surface number and g) as numeric value, and use it as the input for the function Slide. The code is attached below. Any recommendation is highly appreciated.
Bests
for g=1:Nmc %number of monte carlo iterations
for i=1:nx+1
for j=1:ny+1
d(1)=sqrt((xc(i)-P(2,1))^2+(yc(j)-P(2,2))^2); % distance
d(2)=sqrt((xc(i)-P(3,1))^2+(yc(j)-P(3,2))^2); % distance
d(3)=yc(j)-P(2,2)+ H; % distance
R1=min(d);
R2=max(d);
DeltaR=(R2-R1)/nr;
cont=0;
for R=R1:DeltaR:R2
cont=cont+1;
surface=surface+1
C=cell2mat(Csurf{surface,g});%------>line36
[Fb]=slide(rho,C,P,xc(i),yc(j),R,n,KH,KV,MD);
FF(cont,1)=R;
FF(cont,2)=Fb;
end
FFb(i,j)=nanmin(FF(:,2));
for Cont=1:cont
if FFb(i,j)==FF(Cont,2)
RR(i,j)=FF(Cont,1);
end
end
end
end
FFFb=nanmin(nanmin(FFb))
end
  댓글 수: 1
Walter Roberson
Walter Roberson 2021년 5월 15일
you do not show Csurc so it is difficult to say. Perhaps it is empty.

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

채택된 답변

Scott MacKenzie
Scott MacKenzie 2021년 5월 15일
편집: Scott MacKenzie 2021년 5월 15일
It's hard to tell because you haven't stated what Csurf contains. Yes, it's a cell matrix, but a cell matrix containing what?
Having said that, it appears the problem is likely that you are converting twice, using brace indexing and using cell2mat. I suggest you undo one of the conversions by changing ...
C=cell2mat(Csurf{surface,g});
to
C=Csurf{surface,g};
or
C=cell2mat(Csurf(surface,g));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by