フィルターのクリア

Plotting a line, but the line is like a piecewise function

5 ビュー (過去 30 日間)
RetiredCheetoXI
RetiredCheetoXI 2022 年 2 月 7 日
回答済み: Matt J 2022 年 2 月 7 日
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')

採用された回答

Matt J
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 件)

カテゴリ

Help Center および File ExchangeDirected Graphs についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by