Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
problem in if loop
조회 수: 1 (최근 30일)
이전 댓글 표시
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
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!