I have a long code but for this part, I am getting errors. I did for loop and then insert an if statement that includes three conditions, but when running my code, it applies the last conditions for all
if i == 1 && i == 4 %inclined
Kl(1:3,1:3) = HAB*kBAI*HAB'; % kAA
Kl(4:6,1:3) = -kBAI*HAB' ; % kBA
Kl(1:3,4:6) = -HAB*kBAI ; % kAB
Kl(4:6,4:6) = kBAI ; % kBB
KG(1:3,1:3) = lA*Kl(1:3,1:3)*lA' ; % KAA
KG(4:6,1:3) = lB*Kl(4:6,1:3)*lA' ; % KBA
KG(1:3,4:6) = lA*Kl(1:3,4:6)*lB' ; % KAB
KG(4:6,4:6) = lB*Kl(4:6,4:6)*lB' ; % KBB
elseif i == 2 && i == 3 % for curved members
Kl(1:3,1:3) = TAB*kB_curved*TAB'; % kAA
Kl(4:6,1:3) = -kB_curved*TAB'; % kBA
Kl(1:3,4:6) = -TAB*kB_curved ; % kAB
Kl(4:6,4:6) = kB_curved ; % kBB
KG(1:3,1:3) = lA*Kl(1:3,1:3)*lA'; % KAA
KG(4:6,1:3) = lB*Kl(4:6,1:3)*lA' ; % KBA
KG(1:3,4:6) = lA*Kl(1:3,4:6)*lB' ; % KAB
KG(4:6,4:6) = lB*Kl(4:6,4:6)*lB' ; % KBB
else i == 5 && i == 6 % for all straight members
Kl(1:3,1:3) = HAB*kB_straight*HAB' % kAA
Kl(4:6,1:3) = -kB_straight*HAB'; % kBA
Kl(1:3,4:6) = -HAB*kB_straight ; % kAB
Kl(4:6,4:6) = kB_straight ; % kBB
KG(1:3,1:3) = lA*Kl(1:3,1:3)*lA' ; % KAA
KG(4:6,1:3) = lB*Kl(4:6,1:3)*lA' ; % KBA
KG(1:3,4:6) = lA*Kl(1:3,4:6)*lB' ; % KAB
KG(4:6,4:6) = lB*Kl(4:6,4:6)*lB' ; % KBB
end

Respuestas (1)

Walter Roberson
Walter Roberson el 22 de Mzo. de 2022
Editada: Walter Roberson el 22 de Mzo. de 2022
if i == 1 && i == 4 %inclined
There is no value of i such that it is simultaneously true that i equals 1 and i equals 4.
You probably wanted the '||' operator

Categorías

Más información sobre App Building en Centro de ayuda y File Exchange.

Productos

Versión

R2021a

Etiquetas

Preguntada:

el 22 de Mzo. de 2022

Editada:

el 22 de Mzo. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by