简体   繁体   English

由于左侧的索引与右侧的大小不兼容,无法执行分配

[英]Unable to perform assignment because the indices on the left side are not compatible with the size of the right side

When I gave four lambda values then it gives me an error that it's Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.当我给出四个 lambda 值时,它给了我一个错误,它无法执行分配,因为左侧的索引与右侧的大小不兼容。 But for a single value like 36, 38, 40, or 42 it's ok.但是对于像 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);

You didn't initialize VR.你没有初始化 VR。 I suggest you initialize the variable before and plugin values later.我建议您先初始化变量,然后再初始化插件值。 try this before the loop.在循环之前试试这个。

VR=zeros(length(Vs2),length(H1));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法执行分配,因为左侧的索引与右侧的大小不兼容。 这是什么意思? - 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.? 无法执行分配,因为左侧的大小为 1×2,右侧的大小为 2×2 - Unable to perform assignment because the size of the left side is 1-by-2 and the size of the right side is 2-by-2 无法执行赋值,因为左侧的大小为 512×512,右侧的大小为 512×512×3 MATLAB - Unable to perform assignment because the size of the left side is 512-by-512 and the size of the right side is 512-by-512-by-3 MATLAB 无法执行分配,因为左侧和右侧具有不同数量的元素 - Unable to perform assignment because the left and right sides have a different number of elements 无法执行分配,因为左侧和右侧的元素数量不同。 MATLAB 错误 - Unable to perform assignment because the left and right sides have a different number of elements. MATLAB ERROR Matlab:无法执行赋值,因为左侧和右侧的元素数量不同 - Matlab: Unable to perform assignment because the left and right sides have a different number of elements Matlab错误:左侧已初始化,并且索引范围为空。 但是,右侧返回了一个或多个结果 - Matlab error: The left hand side is initialized and has an empty range of indices. However, the right hand side returned one or more results 提升分配运算符的左侧 - Promoting the left hand side of an assignment operator 无法执行分配,因为此类型的变量不支持点索引 - Unable to perform assignment because dot indexing is not supported for variables of this type
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM