Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

problem in if loop

1 visualización (últimos 30 días)
Jeevan Patil
Jeevan Patil el 6 de Mzo. de 2012
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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 comentario
Walter Roberson
Walter Roberson el 6 de Mzo. de 2012
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.

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by