Are there two conditions at once when using the if condition?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello. I have a question and am posting.
I solved it as below, but the value I want is not found, so I ask. Q_1 is entered only when tact is 1 and k is 1, and I am trying to calculate the rest by putting the rest in the expression.
So, when tact is 1 and k is 1, can't we just put the value of Q_1?? For the rest, I try to use the formula below.
Q_1 = 30;
Q_D = 11.3;
Q_E = 8.3;
Q_R = 7.5;
Q_F = 4.5;
connection_D = [1,0,0,0; 0,1,0,0; 0,0,1,0; 0,0,0,1];
connection_E = [0,1,0,0; 0,0,1,0; 0,0,0,1; 1,0,0,0];
connection_F = [0,0,1,0; 0,0,0,1; 1,0,0,0; 0,1,0,0];
connection_R = [0,0,0,1; 1,0,0,0; 0,1,0,0; 0,0,1,0];
for tact = 1:4
for k=1:4
if k==1
Q_column(1)=Q_1
else
Q_column(k) = Q_column(k-1) + Q_D*connection_D(tact,k) - Q_E*connection_E(tact,k) + Q_F*connection_F(tact,k) - Q_R*connection_R(tact,k)
end
end
end
1 comentario
Respuestas (1)
Prince Kumar
el 25 de En. de 2022
Hi,
Q_1 = 30;
Q_D = 11.3;
Q_E = 8.3;
Q_R = 7.5;
Q_F = 4.5;
connection_D = [1,0,0,0; 0,1,0,0; 0,0,1,0; 0,0,0,1];
connection_E = [0,1,0,0; 0,0,1,0; 0,0,0,1; 1,0,0,0];
connection_F = [0,0,1,0; 0,0,0,1; 1,0,0,0; 0,1,0,0];
connection_R = [0,0,0,1; 1,0,0,0; 0,1,0,0; 0,0,1,0];
for tact = 1:4
for k=1:4
if k==1 & tact == 1
Q_column(1)=Q_1
else
Q_column(k) = Q_column(k-1) + Q_D*connection_D(tact,k) - Q_E*connection_E(tact,k) + Q_F*connection_F(tact,k) - Q_R*connection_R(tact,k)
end
end
end
You can use any combination of operators as per your need.
Hope this helps.
0 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!