Borrar filtros
Borrar filtros

How do I plot a horizontal line on my existing graph?

8 visualizaciones (últimos 30 días)
Wilbur
Wilbur el 15 de Jun. de 2023
Respondida: Dyuman Joshi el 15 de Jun. de 2023
I have a MATLAB plot of a graph consisting of values input into a matrix R of size R x 1.
On the same graph I want to plot a horizontal line of fixed value k.
How do I do this? I tried using the yline() function to no avail.
My code to plot the graph is:
plot(R)
Trying to add the horizontal line I tried:
plot(R,yline(k))
But it does not work. Any advice?

Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 15 de Jun. de 2023
You need to use it as a separate command
%Random data for example
R = rand(10,1);
k = rand;
%plot the matrix
plot(R)
yline(k)

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by