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

답변 (1개)

Walter Roberson
Walter Roberson 2022년 3월 22일
편집: Walter Roberson 2022년 3월 22일

1 개 추천

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

카테고리

도움말 센터 및 File Exchange에서 App Building에 대해 자세히 알아보기

제품

릴리스

R2021a

태그

질문:

2022년 3월 22일

편집:

2022년 3월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by