Unable to run my function even though my textbook was able to get it done this way...
even when I put the value of fs in, it still gives errors...

2 commentaires

Walter Roberson
Walter Roberson le 10 Mai 2023
When you run your function by pressing the green Run button, where are you expecting MATLAB to look for values for z?
Roos
Roos le 11 Mai 2023
I was asked to test dfdt using the test signal: and check if the plotted signal resembles the analytically obtained derivative of z(t) = sin(2*pi*f*t).

Connectez-vous pour commenter.

 Réponse acceptée

Torsten
Torsten le 10 Mai 2023
Déplacé(e) : Torsten le 10 Mai 2023

0 votes

The code line in the loop must read
za(i) = (z(i+1)-z(i-1))/(2*h)
instead of
za(i) = (z(i+1)-(i-1))/(2*h)
And call the function with reasonable inputs, e.g.
x = 0:0.1:1;
z = sin(x);
fs = 10;
za = dfdt(z,fs)
plot(x,za)

Plus de réponses (0)

Catégories

En savoir plus sur Language Fundamentals dans Centre d'aide et File Exchange

Produits

Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by