Plot horizontal line over existing plot (on same figure)

Hi all!
I have to plot a horizontal (threshold) line over a graph obtained by means of a for loop. my matlab version is 2014a.
This is the script:
for i=1:18
figure(1)
title('Max Temperature','fontsize',20)
xlabel('n° sensor','fontsize',15)
ylabel('Temperature [°]','fontsize',15)
plot(i,Max_Temp(1,i),'o')
hold on
grid on
end
How can I do? Thank you very much.

 採用された回答

Cameron
Cameron 2023 年 1 月 17 日
編集済み: Cameron 2023 年 1 月 17 日

0 投票

You didn't specify what the y value of your graph needs to be, but you can take the information in this post and adjust it as needed. I also reconfigured some of your code a bit.
figure(1)
title('Max Temperature','fontsize',20)
xlabel('n° sensor','fontsize',15)
ylabel('Temperature [°]','fontsize',15)
hold on
grid on
for i=1:18
plot(i,Max_Temp(1,i),'o')
end
x = 1:18;
y = ones(1,length(x))*200; %I just made up a value of 200. Put whatever your threshold is here.
plot(x,y,'-k')
hold off

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

タグ

質問済み:

2023 年 1 月 17 日

コメント済み:

2023 年 1 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by