Is there an error in the if else statement?

1 回表示 (過去 30 日間)
SK dawn
SK dawn 2021 年 11 月 1 日
コメント済み: SK dawn 2021 年 11 月 6 日
when I try to enter the code the system does not run, it all happened when I added the if else statment so whats wrong?
>> % Known Variables:
L1 = 16.87; %cm
L2 = 60.35;
L3 = 16.81;
L4 = 63.06;
L5 = 42.62;
L7 = 19.64;
theta_1 = 105.47; %degree
theta_3 = 270;
theta_5 = 115.38;
theta_triangle = ;
v = 2.95;
for t = 0 : 0.1 : 10;
LA= 29.71+ v*t;
%solving for theta 6(actuator) and theta7
Z = L5*exp(i*deg2rad(theta_5));
Zc = conj(Z);
A = L7*Zc;
B = Z*Zc +L7^2 -LA.^2;
C = L7*Z;
Q = (-B - sqrt(B^2 -4*A*C))/2*A;
Q_1 = (-B+ sqrt(B^2 -4*A*C))/2*A;
W= ((L7*Q)+Z)/LA;
W_1 = ((L7*Q_1)+Z)/LA;
theta_7 = rad2deg(angle(Q));
theta_7_1_ = rad2deg(angle(Q_1));
theta_6 = rad2deg(angle(W));
theta_6_1 = rad2deg(angle(W_1));
if theta_7>90
theta_7_Final =360-theta_7;
else if theta_7>-180
theta_7_Final =180-theta_7_1;
else theta_7_Final =180-theta_7_1;
theta_6_Final = 180+theta_6_1
theta_4_Final= theta_7_Final - theta_triangle
end

採用された回答

Alan Stevens
Alan Stevens 2021 年 11 月 1 日
Yes, among others! See:
L1 = 16.87; %cm
L2 = 60.35;
L3 = 16.81;
L4 = 63.06;
L5 = 42.62;
L7 = 19.64;
theta_1 = 105.47; %degree
theta_3 = 270;
theta_5 = 115.38;
theta_triangle = 100 ; %%%%%%%%%%%%%%%%%% You had no value here!
v = 2.95;
for t = 0 : 0.1 : 10
LA= 29.71+ v*t;
%solving for theta 6(actuator) and theta7
Z = L5*exp(1i*deg2rad(theta_5));
Zc = conj(Z);
A = L7*Zc;
B = Z*Zc +L7^2 -LA.^2;
C = L7*Z;
Q = (-B - sqrt(B^2 -4*A*C))/2*A;
Q_1 = (-B+ sqrt(B^2 -4*A*C))/2*A;
W= ((L7*Q)+Z)/LA;
W_1 = ((L7*Q_1)+Z)/LA;
theta_7 = rad2deg(angle(Q));
theta_7_1 = rad2deg(angle(Q_1)); %%%%%%%%%%% You had theta_7_1_ here instead of theta_7_1
theta_6 = rad2deg(angle(W));
theta_6_1 = rad2deg(angle(W_1));
if theta_7>90
theta_7_Final =360-theta_7;
elseif theta_7>-180 %%%%%%%%% elseif not else if
theta_7_Final =180-theta_7_1;
else
theta_7_Final =180-theta_7_1;
theta_6_Final = 180+theta_6_1;
theta_4_Final= theta_7_Final - theta_triangle;
end
end %%%%%%%%%%%%% There was an end missing
  1 件のコメント
SK dawn
SK dawn 2021 年 11 月 6 日
thank you

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePropagation and Channel Models についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by