Why does my sin graph look like a triangle?

댓글 수: 4

We would have to know what your function dfdt is doing in order to say for certain. Please copy/paste all your code here so we can run it and see.
James Tursa
James Tursa 2023년 5월 10일
@Roos Never post code as an image ... we can't run images at our end. Please always post code as regular text highlighted with the CODE button.
Roos
Roos 2023년 5월 11일
편집: Roos 2023년 5월 11일
@Cris LaPierre @James Tursa , here you go, sorry I did not realize we could not send photos
function za = dfdt (z,fs)
% za = dfdt (z,fs)
% determines numerically the derivative za
% of signal z.
% z is registered at sampling frequency fs.
h = 1/fs;
n =length (z);
for i = 2:n-1
za (i) = (z(i+1) - z(i-1))/(2*h);
end
za(1)= (z(2)-z(1))/h;
za(n)= (z(n)-z(n-1))/h;
You can obviously post pictures, but then you are asking the community to rewrite yout code from a picture. It's much simpler for us if you just copy/paste your code instead.

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

답변 (1개)

Cris LaPierre
Cris LaPierre 2023년 5월 10일

0 개 추천

Your sin wave is plotted just fine. However, it looks like a straight line because the magnitude of your second plot (in red) is so much larger (1 vs 5e5)

댓글 수: 3

Roos
Roos 2023년 5월 11일
how do I change the magnitude?
Stephen23
Stephen23 2023년 5월 11일
편집: Stephen23 2023년 5월 11일
"how do I change the magnitude?"
Rather than changing your data, I suspect that YYAXIS or PLOTYY is what you are looking for:
Cris LaPierre
Cris LaPierre 2023년 5월 11일
편집: Cris LaPierre 2023년 5월 11일
BTW, the derivative of sin is cosine. So the correct plot should show a sin and cosine wave of the same frequency and amplitude.

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

카테고리

도움말 센터File Exchange에서 Axis Labels에 대해 자세히 알아보기

제품

릴리스

R2023a

질문:

2023년 5월 10일

편집:

2023년 5월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by