Defining and plotting a piecewise function
์กฐํ ์: 7 (์ต๊ทผ 30์ผ)
์ด์ ๋๊ธ ํ์
Majd Salhab
2020๋
4์ 16์ผ
๋๊ธ: Star Strider
2020๋
4์ 16์ผ
Hi everybody!
I am trying to deifne and plot the function below in matlab, without success. Can anybody point how I could plot this function?
for 0 <= T < Tb, Se(T) = ag*S*?*F0*[(T/Tb) + (1/?*F0)*(1 - T/Tb)]
for Tb <= T < Tc, Se(T) = ag*S*?*F0
for Tc <= T < Td, Se(T) = ag*S*?*F0*(Tc/T)
for Td <= T, Se(T) = ag*S*?*F0*(Tc*Td/(T^2))
Note: I have defined all values of ag, S, n, F0, Tb, Tc, Td in my code.
function S = f(T);
S=0;
if T >= 0 & T < Tb
S = ag*S*n*F0*[(T/Tb) + (1/n*F0)*(1 - T/Tb)];
elseif T >= Tb & T < Tc
S = ag*S*n*F0;
elseif T >= Tc & T < Td
S = ag*S*n*F0*(Tc/T);
else T>=Td
S = ag*S*n*F0*(Tc*Td/(T.^2));
end
end
Thanks!
๋๊ธ ์: 0
์ฑํ๋ ๋ต๋ณ
Star Strider
2020๋
4์ 16์ผ
Another option:
S = @(T) (ag*S*n*F0*((T/Tb) + (1/n*F0)*(1 - T/Tb))).*(T >= 0 & T < Tb) + (ag*S*n*F0).*(T >= Tb & T < Tc) + (ag*S*n*F0*(Tc*Td/(T.^2))).*(T >= Tc & T < Td);
If all the other values are scalars, that should work.
.
๋๊ธ ์: 8
์ถ๊ฐ ๋ต๋ณ (1๊ฐ)
Ameer Hamza
2020๋
4์ 16์ผ
See piecewise(): https://www.mathworks.com/help/releases/R2020a/symbolic/piecewise.html. You can use it with symbolic toolbox to define a piecewise function.
๋๊ธ ์: 0
์ฐธ๊ณ ํญ๋ชฉ
์นดํ ๊ณ ๋ฆฌ
Help Center ๋ฐ File Exchange์์ Annotations์ ๋ํด ์์ธํ ์์๋ณด๊ธฐ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!