Brace indexing is not supported for variables of this type.

1 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

Scott MacKenzie
Scott MacKenzie am 15 Mai 2021
Bearbeitet: Scott MacKenzie am 15 Mai 2021
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));

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by