Unable to perform assignment because the left and right sides have a different number of elements.
조회 수: 1 (최근 30일)
이전 댓글 표시
I am getting error like this :Unable to perform assignment because the left and right sides have a different number of elements.
Error in classicalL (line 160)
EL(i)=Ef.*Vf+Em.*(1-Vf);
I am attaching my code. If you run the code the following questions will be asked. I already defined the values. so please click ok until u get error.
Thanks in advance.
댓글 수: 0
답변 (2개)
Cris LaPierre
2020년 6월 26일
No error for me, but I had to guess what values to use for Lambda.
This error message occurs when your expression on the right creates a vector of numbers, but you are assigning it to a single entry (EL(i)).
Inspect the values of Ef, Vf, and Em to make sure they are always creating the values you expect.
댓글 수: 5
Cris LaPierre
2020년 6월 27일
Again, when I run your code, I do not get an error. I would like to know what values you are entering in each prompt. Specifically, what values are you using for lambda?
Cris LaPierre
2020년 6월 28일
The issue is you create Ef, Vf, Em as well as several other variables as vectors.
Ef(i)=prec(1)*10^9; %Elastic Modulus of Fiber
Ep(i)=prec(2)*10^9;
Em(i)=prec(3)*10^9; %Elastic Modulus of Matrix
Gf(i)=prec(4)*10^9; %Shear Modulus of Fiber
Gm(i)=prec(5)*10^9; %shear Modulus of Matrix
vf(i)=prec(6); %Poison's Ratio of Fiber
vm(i)=prec(7); %Poison's Ratio of Matrix
Vf(i)=prec(8); %Volume Fiber Fraction
Df(i)=prec(9); %Density of Fiber
Dm(i)=prec(10); %Density Ratio of Matrix
You probably want your equation to index these variables as well.
EL(i)=Ef(i).*Vf(i)+Em(i).*(1-Vf(i));
You'll have to make a similar change to all your equations.
ET(i)=Ep.*Em/Em.*Vf+Ep.*(1-Vf);
vL(i)=vf.*Vf+vm.*(1-Vf);
vT(i)=ET.*vL/EL;
GLT(i)=Gf.*Gm/(Gm.*Vf+Gf.*(1-Vf));
GTL(i)=ET/(2.*(1+vT));
Den(i)=Df.*Vf+Dm.*(1-Vf);
댓글 수: 3
Cris LaPierre
2020년 6월 29일
The error message is fairly easy to understand. For the condition you specify, you do not define theta. This pertains to the code between lines 138 and 170 in the updated file.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!