Brace indexing is not supported for variables of this type.
4 次查看(过去 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!