Why does my sin graph look like a triangle?

3 visualizaciones (últimos 30 días)
Roos
Roos el 10 de Mayo de 2023
Editada: Cris LaPierre el 11 de Mayo de 2023
  4 comentarios
Roos
Roos el 11 de Mayo de 2023
Editada: Roos el 11 de Mayo de 2023
@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;
Cris LaPierre
Cris LaPierre el 11 de Mayo de 2023
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.

Iniciar sesión para comentar.

Respuestas (1)

Cris LaPierre
Cris LaPierre el 10 de Mayo de 2023
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 comentarios
Stephen23
Stephen23 el 11 de Mayo de 2023
Editada: Stephen23 el 11 de Mayo de 2023
"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 el 11 de Mayo de 2023
Editada: Cris LaPierre el 11 de Mayo de 2023
BTW, the derivative of sin is cosine. So the correct plot should show a sin and cosine wave of the same frequency and amplitude.

Iniciar sesión para comentar.

Categorías

Más información sobre Two y-axis en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by