フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

problem in if loop

1 回表示 (過去 30 日間)
Jeevan Patil
Jeevan Patil 2012 年 3 月 6 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Dear friends, I want to program following equation. when x1>a1 & x2>a2 F1 = -P21*Apb+Pa*Apt - Fpi - Ff1;
F2 = -P21*Apvt + P11*Apvb - Fpvi - Ff2;
F3 = P13*Ast - P22*Asb - Fsi - Ff3;
F4 = -P12*Asvb+P22*Asvt-Fsvi-Ff4;
when x1>a1 & x2<=a2
F1 = -P21*Apb+Pa*Apt - Fpi - Ff1;
F2 = -P21*Apvt + P11*Apvb - Fpvi - Ff2;
F3 = P13*Ast - P22*Asb - Fsi - Ff3;
F4 = -P12*Asvb+P22*Asvt-Fsvi; % when x1<=a1 x2<=0
F1 = -P21*Apb+Pa*Apt - Fpi - Ff1;
F2 = -P21*Apvt + P11*Apvb - Fpvi;
F3 = P13*Ast - P22*Asb - Fsi;
F4 = -P12*Asvb+P22*Asvt-Fsvi;
Below given is my matlab script. in this i am not able to figure out why the out put of this program is contact when t is varying from 0 to 10.
t = 0:0.01:10; x1 = 13*sin(t); x2 = 13*sin(t);
for i = 1:length(t);
if x1<=a1 & x2<=0
F1(i) = -P21*Apb+Pa*Apt - Fpi - Ff1;
F2(i) = -P21*Apvt + P11*Apvb - Fpvi;
F3(i) = P13*Ast - P22*Asb - Fsi;
F4(i) = -P12*Asvb+P22*Asvt-Fsvi;
elseif x1>a1 & x2<=a2
F1(i) = -P21*Apb+Pa*Apt - Fpi - Ff1;
F2(i) = -P21*Apvt + P11*Apvb - Fpvi - Ff2;
F3(i) = P13*Ast - P22*Asb - Fsi - Ff3;
F4(i) = -P12*Asvb+P22*Asvt-Fsvi; elseif x1>a1 & x2>a2
F1(i) = -P21*Apb+Pa*Apt - Fpi - Ff1;
F2(i) = -P21*Apvt + P11*Apvb - Fpvi - Ff2;
F3(i) = P13*Ast - P22*Asb - Fsi - Ff3;
F4(i) = -P12*Asvb+P22*Asvt-Fsvi-Ff4; end end
  1 件のコメント
Walter Roberson
Walter Roberson 2012 年 3 月 6 日
There is no such thing as an "if loop". "if" is a sequential control statement, and the body of an "if" is executed only once, not in a loop.

回答 (0 件)

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by