Plotting a line, but the line is like a piecewise function
1 回表示 (過去 30 日間)
古いコメントを表示
I am calculating Temperature when given altiude. For different values of h, the temperature will either fall under an equation or it will be a constant number. Is there a way to graph a continuous line that uses all of these segments? It is already showing a single point on the graph that is the h and calculated T value, I'd like that to show up on the graph as well.
function [h, a] = Temperature(T)
prompt = 'Altitude (m) ';
h = input(prompt);
if (h <= 11000)
T = (h - 44332.30769230768) / -153.84615384615378
elseif (h <= 25000)
T = 216.66
elseif (h <= 47000)
T = (h + 47220) / 333.3
elseif (h <= 53000)
T = 282.66
elseif (h <= 79000)
T = (h - 115813) / -222.2
elseif (h <= 90000)
T = 165.66
elseif (h <= 110000)
T = (h - 48585) / 250
end
plot(T, h, 'o')
0 件のコメント
採用された回答
Matt J
2022 年 2 月 7 日
hdata=linspace(0,110000,1000);
Tdata=arrayfun(@Temperature,hdata);
plot(hdata,Tdata, 'o')
function T = Temperature(h)
if (h <= 11000)
T = (h - 44332.30769230768) / -153.84615384615378;
elseif (h <= 25000)
T = 216.66;
elseif (h <= 47000)
T = (h + 47220) / 333.3;
elseif (h <= 53000)
T = 282.66;
elseif (h <= 79000)
T = (h - 115813) / -222.2;
elseif (h <= 90000)
T = 165.66;
elseif (h <= 110000)
T = (h - 48585) / 250;
end
end
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!