how do i plot y=6sin(t+0.5) and y=5 between 0 and 20 in steps of 0.001

1 visualización (últimos 30 días)
Zack
Zack el 23 de Abr. de 2023
Respondida: Aditya Srikar el 28 de Abr. de 2023
how do i plot y=6sin(t+0.5) and y=5 between 0 and 20 in steps of 0.001
  4 comentarios
Zack
Zack el 23 de Abr. de 2023
x= 0 : 0.001 : 20;
y1= 6*sin(t+0.5);
y2= 5;
plot(t,y1,t,y2)
grid
xlabel('x units')
ylabel('y')
getting a error for y1. any help is much appricated
Torsten
Torsten el 23 de Abr. de 2023
Editada: Torsten el 23 de Abr. de 2023
You don't define t in your code. Shouldn't it be x ?
And if you do it this way:
y2 = 5*ones(size(x))
instead of
y2 = 5

Iniciar sesión para comentar.

Respuestas (1)

Aditya Srikar
Aditya Srikar el 28 de Abr. de 2023
Hi Zack
The following code will display the plot as required
x= 0 : 0.001 : 20;
y= 6*sin(x+0.5);
plot(x, y, 'green')
hold on
yline(5, 'red')
grid
xlabel('x units')
ylabel('y units')
hold off
Hope it helps !

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by