How do I fix the values on my x-axis to go from 0 to 2?
My intention is to plot y=8*cos(2*π*x) and y=8*cos(19*π*x)*exp(-x)
where where x is from 0 to 2 and y is from -8 to 8.
if any one could give me the correct code it would be much appreciated.

 채택된 답변

Mathieu NOE
Mathieu NOE 2021년 4월 2일

1 개 추천

hello
here you are :
x = 0:1e-3:2;
y1=8*cos(2*pi*x);
y2=8*cos(19*pi*x).*exp(-x);
figure(1),plot(x,y1,x,y2)

댓글 수: 5

Ayush Kumar
Ayush Kumar 2021년 4월 2일
wow! thanks a lot!
Mathieu NOE
Mathieu NOE 2021년 4월 2일
you're welcome
Ayush Kumar
Ayush Kumar 2021년 4월 2일
btw, is there a way where I can also add a function y=0 (basically i want to insert the x-axis as a line it self to symmetrically split the plot in halves)?
sure
you can do it this way :
x = 0:1e-3:2;
y0=zeros(size(x));
y1=8*cos(2*pi*x);
y2=8*cos(19*pi*x).*exp(-x);
figure(1),plot(x,y0,x,y1,x,y2)
Ayush Kumar
Ayush Kumar 2021년 4월 2일
thanks a lot!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2021년 4월 2일

댓글:

2021년 4월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by