![](/img/trans.png)
[英]Unable to perform assignment because the indices on the left side are not compatible with the size of the right side. What does this mean?
[英]Unable to perform assignment because the indices on the left side are not compatible with the size of the right side
当我给出四个 lambda 值时,它给了我一个错误,它无法执行分配,因为左侧的索引与右侧的大小不兼容。 但是对于像 36、38、40 或 42 这样的单个值,没关系。
R = [0.5:0.1:2.25];
Vs1= [120];
Vs2 = R.*Vs1;
H1=[5:5:25];
rho = [2000 2000];
lambda = [36 38 40 42];
for j=1:length(Vs2),
Vs = [Vs1 Vs2(j)];
for i=1:length(H1)
H2=30-H1(i);
d=[H1(i),H2];
Vs30(j,i)=Vs30_fun(d,Vs);
end
end
for j=1:length(Vs2),
Vs = [Vs1 Vs2(j)];Vp=2.*Vs;
for i=1:length(H1)
d=[H1(i) Inf];
VR(j,i)=lv_fun(d,Vs,Vp,rho,lambda);
end
end
M=VR<Vs30;
[m,n]=size(M);
VR=zeros(length(Vs2),length(H1));
for i=1:m
for j=1:n
if M(i,j)==0
plot(H1(i),R(j), 'r*')
hold on
% drawnow();
end
end
end
VR(j,i)=lv_fun(d,Vs,Vp,rho,lambda);
你没有初始化 VR。 我建议您先初始化变量,然后再初始化插件值。 在循环之前试试这个。
VR=zeros(length(Vs2),length(H1));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.