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
채택된 답변
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 Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!