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.

답변 (2개)

Cris LaPierre
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
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?
Sairama Krishnam Pothuri
Sairama Krishnam Pothuri 2020년 6월 28일
Hi Cris Lapierre,
Thank you again for giving me answers with patience. Sorry I have defined wrong values in prompts. Instead of (2 in question 4 and 2 in question 5) I have defined (1 in question 4 and 1 in question 5) in previous code. Sorry It was my mistake But now I have changed. So again I am attaching my code with defined values in prompts. please check it or you please define the values like this:
If u run the code the following questions will be asked.
For question 1: please enter - 4
For question 2: please enter - 1
For question 3: please enter - 1
For question 4: please enter - 2
For question 5: please enter - 2
After this for the remaining I already defined the values. Only u need to define for the questions is :
For lamina 1 orientation: please enter - 0(Zero)
For lamina 2 orientation: please enter - 90
For lamina 3 orientation: please enter - 90
For lamina 4 orientation: please enter - 0(zero)
I am getting the error like this If I run the code by defining the above values:
This is error I am getting When I run the program. I didnt understand why I am getting this.
Error:
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);
Thanks in advance.

댓글을 달려면 로그인하십시오.


Cris LaPierre
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
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Historical Contests에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by