Help With Nested IF Statements!!!

1 view (last 30 days)
Omar
Omar on 23 Mar 2020
Commented: Omar on 24 Mar 2020
I would really appreciate if someone can help me why I am not getting the graph in the picture using the following code:
clear all;
clc;
close all;
Ss = 0.263;
S1 = 0.103;
Fa = 0.8;
Fv = 0.8;
TL = 10;
Sms = Fa*Ss;
Sm1 = Fv*S1;
Sds = (2/3)*Sms;
Sd1 = (2/3)*Sm1;
To = 0.2*(Sd1/Sds);
Ts = (Sd1/Sds);
T11 = [0:0.01:To]; T12 = T11(end)+0.0083; T1 = [T11,T12];
T21 = T1(end)+0.01:0.01:Ts; T22 = [T21(end)+0.0033]; T2 = [T21,T22];
T31 = T2(end)+0.01:0.01:TL; T32 = [T31(end)+0.0084]; T3 = [T31,T32];
T4 = T3(end)+0.01:0.01:12;
T = [T1,T2,T3,T4];
for j = 1:1:length(T)
Sa(1) = Sd1;
if T > 0 & T <= To
Sa(j) = Sds*(0.4+0.6*(T(j)/To));
elseif T > To & T <= Ts
Sa(j) = Sds;
elseif T > Ts & T <= TL
Sa(j) = Sd1/T(j);
else
Sa(j) = Sd1*TL/T(j)^2;
end
end

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 23 Mar 2020
if T > 0 & T <= To
needs to be
if T(j) > 0 & T(j) <= To

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!