Brace indexing is not supported for variables of this type.

1 回表示 (過去 30 日間)
Pooneh Shah Malekpoor
Pooneh Shah Malekpoor 2021 年 5 月 15 日
編集済み: Scott MacKenzie 2021 年 5 月 15 日
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));
  1 件のコメント
Pooneh Shah Malekpoor
Pooneh Shah Malekpoor 2021 年 5 月 15 日
編集済み: Pooneh Shah Malekpoor 2021 年 5 月 15 日
Yes!the second one. Thanks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by