error:An array for multiple LHS assignment cannot contain expressions.

Error: File: Q7.m Line: 12 Column: 2
What does the error mean?
I'm using Matlab to solve Mechanism problems,and here is my code.
I'm pretty sure that it's not InverseRR's problem.I have used that function in other problems ,and it worked.
Hope that somebody who good at it could help me,please><
clc
clear
a1 = 15 ; a2 = 30 ; a3 = 20 ; a4 = 30 ; alpha = 30;
Xq = 50 ; Yq = 8 ; Xr = 70 ; Yr = 8;
dXa = 10 ; dYa = 0;
Xa = 20 ;Ya = a1 ;
I = 1;
BC = sqrt(a3^2 + a4^2 - 2 * a3 * a4 * cos(alpha)) ;
[(theta04),(theta02),dtheta4,dtheta2,ddtheta4,ddtheta2] = InverseRR(Xq,Yq,a3,a2,Xa,Ya,dXa,dYa,ddXa,ddYa,I);
theta2 = theta02 - 180;
theta4 = theta04 - alpha;

7 件のコメント

madhan ravi
madhan ravi 2018 年 11 月 18 日
InverseRR is a function defined by you? if so upload it
Yi-Le Li
Yi-Le Li 2018 年 11 月 18 日
編集済み: madhan ravi 2018 年 11 月 18 日
Yes :(
function[PHI,PSI,dPHI,dPSI,ddPHI,ddPSI] = InverseRR(Xq,Yq,c,b,Xa,Ya,dXa,dYa,ddXa,ddYa,I)
X = Xa - Xq;
Y = Ya - Yq;
A = 2 * c* Y;
B = 2 * c * X;
C = X^2 + Y^2 + c^2 - b^2;
t1 = (A + sqrt(A^2+B^2-C^2))/(C+B);
t2 = (A - sqrt(A^2+B^2-C^2))/(C+B);
if (I == 1)
t = t1;
else
t = t2;
end
PHI = 2*atan(t);
U = (X- c*cos(PHI))/b;
V = (Y- c*sin(PHI))/b;
PSI = atan2(V,U);
Xb = c*cos(PHI);
Yb = c*sin(PHI);
%%% Inverse Velocity%%%
dX = dXa;
dY = dYa;
D = [ -c * sin(PHI) -b * sin(PSI), c * cos(PHI) b * cos(PSI) ];
E = [ dX,
dY ];
F = D \ E ;
dPHI = F(1,1);
dPSI = F(2,1);
%%% Inverse Acceleration %%%
ddX = ddXa;
ddY = ddYa;
G = [ -c * sin(PHI) -b * sin(PSI),
c * cos(PHI) b * cos(PSI) ];
H = [ ddX + c * cos(PHI) * dPHI ^2 - b * cos(PSI) * dPSI ^2 ,
ddY + c * cos(PHI) * dPHI ^2 - b * sin(PSI) * dPSI ^2 ] ;
I = G \ H;
ddPHI = I(1,1);
ddPSI = I(2,1);
PHI = PHI / pi * 180;
PSI = PSI / pi * 180;
end
madhan ravi
madhan ravi 2018 年 11 月 18 日
you didn't provide the value for ddXa,ddYa
Yi-Le Li
Yi-Le Li 2018 年 11 月 18 日
Oh!I think we solved the problem xD
I provided ddXa,ddYa to the code,but it still can't work,and then I delete the Parentheses of theta02 and theta04 , and the error was gone !
Thanks for helping me!!!!
Stephen23
Stephen23 2018 年 11 月 18 日
@Yi-Le Li: please show the complete error message. This means all of the red text.
madhan ravi
madhan ravi 2018 年 11 月 18 日
@Yi no you will still have error see my answer below
Yi-Le Li
Yi-Le Li 2018 年 11 月 18 日
@Stephen Cobeldick
>> Q7
Error: File: Q7.m Line: 12 Column: 2
An array for multiple LHS assignment cannot contain expressions.

サインインしてコメントする。

 採用された回答

Bruno Luong
Bruno Luong 2018 年 11 月 18 日
編集済み: Bruno Luong 2018 年 11 月 18 日

0 投票

Remove the parenthesis
[theta04,theta02,dtheta4,dtheta2,ddtheta4,ddtheta2] = InverseRR...

3 件のコメント

Yi-Le Li
Yi-Le Li 2018 年 11 月 18 日
I tried it ,and it works!!
Thank you :D
But I'm still a little confused about it.Can you tell me what the parentheses here mean?
Bruno Luong
Bruno Luong 2018 年 11 月 18 日
it means you get the error! Parenthesis on LHS is not valid syntax so why you ask me the meaning?
Yi-Le Li
Yi-Le Li 2018 年 11 月 18 日
Oh!!Got it !! I'm a new matlab learner.
Thank you so much for helping me solve it !!

サインインしてコメントする。

その他の回答 (1 件)

madhan ravi
madhan ravi 2018 年 11 月 18 日
編集済み: madhan ravi 2018 年 11 月 18 日

0 投票

The problem in your code was you put comma ( , ) instead of semicolon ( ; )
Reason see mldivide
a1 = 15 ; a2 = 30 ; a3 = 20 ; a4 = 30 ; alpha = 30;
Xq = 50 ; Yq = 8 ; Xr = 70 ; Yr = 8;
dXa = 10 ; dYa = 0;
Xa = 20 ;Ya = a1 ;
I = 1;
ddXa=3; %fake data change it to your value
ddYa=5; %fake data change it to your value
BC = sqrt(a3^2 + a4^2 - 2 * a3 * a4 * cos(alpha)) ;
%|------||------|----error was here
[theta04,theta02,dtheta4,dtheta2,ddtheta4,ddtheta2] = InverseRR(Xq,Yq,a3,a2,Xa,Ya,dXa,dYa,ddXa,ddYa,I);
theta2 = theta02 - 180;
theta4 = theta04 - alpha;
function[PHI,PSI,dPHI,dPSI,ddPHI,ddPSI] = InverseRR(Xq,Yq,c,b,Xa,Ya,dXa,dYa,ddXa,ddYa,I)
X = Xa - Xq;
Y = Ya - Yq;
A = 2 * c* Y;
B = 2 * c * X;
C = X^2 + Y^2 + c^2 - b^2;
t1 = (A + sqrt(A^2+B^2-C^2))/(C+B);
t2 = (A - sqrt(A^2+B^2-C^2))/(C+B);
if (I == 1)
t = t1;
else
t = t2;
end
PHI = 2*atan(t);
U = (X- c*cos(PHI))/b;
V = (Y- c*sin(PHI))/b;
PSI = atan2(V,U);
Xb = c*cos(PHI);
Yb = c*sin(PHI);
%%% Inverse Velocity%%%
dX = dXa;
dY = dYa;
D = [ -c * sin(PHI) -b * sin(PSI); c * cos(PHI) b * cos(PSI) ];
% ^--------- error was here
E = [ dX;
dY ];
F = D \ E ;
dPHI = F(1,1);
dPSI = F(2,1);
%%% Inverse Acceleration %%%
ddX = ddXa;
ddY = ddYa;
G = [ -c * sin(PHI) -b * sin(PSI); %error was here
c * cos(PHI) b * cos(PSI) ];
H = [ ddX + c * cos(PHI) * dPHI ^2 - b * cos(PSI) * dPSI ^2 ; %error was here
ddY + c * cos(PHI) * dPHI ^2 - b * sin(PSI) * dPSI ^2 ] ;
I = G \ H;
ddPHI = I(1,1);
ddPSI = I(2,1);
PHI = PHI / pi * 180;
PSI = PSI / pi * 180;
end

1 件のコメント

Stephen23
Stephen23 2018 年 11 月 18 日
"The problem in your code was you put comma ( , ) instead of semicolon ( ; )"
Where? And why is this a problem?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

タグ

質問済み:

2018 年 11 月 18 日

編集済み:

2018 年 11 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by