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 Kommentare

Walter Roberson
Walter Roberson am 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 am 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).

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Torsten
Torsten am 10 Mai 2023
Verschoben: Torsten am 10 Mai 2023

0 Stimmen

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)

Weitere Antworten (0)

Kategorien

Mehr zu Language Fundamentals finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2023a

Gefragt:

am 10 Mai 2023

Kommentiert:

am 11 Mai 2023

Community Treasure Hunt

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

Start Hunting!

Translated by