필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Zack
Zack 2023년 4월 23일
답변: Aditya Srikar 2023년 4월 28일
how do i plot y=6sin(t+0.5) and y=5 between 0 and 20 in steps of 0.001
  댓글 수: 4
Zack
Zack 2023년 4월 23일
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 2023년 4월 23일
편집: Torsten 2023년 4월 23일
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

댓글을 달려면 로그인하십시오.

답변 (1개)

Aditya Srikar
Aditya Srikar 2023년 4월 28일
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 !

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by