Plotting straight line on graph

Hey easy question but how do i plot the line y=40 in matlab? What is the script i need to write?
Thanks zane :)

 Accepted Answer

Simon
Simon on 15 Oct 2023
Moved: Matt J on 15 Oct 2023
yline(40)

1 Comment

Note that yline is available from R2018b onwards.
In case of an older version, use the method described in the other answer.

Sign in to comment.

More Answers (2)

plot([first_x last_x], 40)

2 Comments

this does not work
plot([first_x last_x], [40,40])

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!