I need help graphing a function.
조회 수: 1 (최근 30일)
이전 댓글 표시
The code creates a graph but I'm pretty sure it's wrong because It's supposed to look closer to a cos(x) graph
t=linspace(0,100,101);
y=(3.*((2.71828).^(-t./2))).*(cos(4.*pi.*t));
plot(t,y);
grid
댓글 수: 0
채택된 답변
Star Strider
2023년 9월 27일
It probably should be a decaying sinusoid.
The problem is that it decays too fast. Decreasing the magnitude of ‘t’ helps to visualise it correctly. (I suspect the problem is the ‘exp(-t./2)’ term. The constant should be smaller than 0.5 to get the result you lilely want with the original ‘t’.)
t=linspace(0,100,101)/10;
y = 3.*exp(-t./2).*cos(4.*pi.*t);
plot(t,y);
grid
.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!