Error in dfdt (line 3)

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 Comments

When you run your function by pressing the green Run button, where are you expecting MATLAB to look for values for z?
Roos
Roos on 11 May 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).

Sign in to comment.

 Accepted Answer

Torsten
Torsten on 10 May 2023
Moved: Torsten on 10 May 2023
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)

More Answers (0)

Categories

Find more on Language Fundamentals in Help Center and File Exchange

Products

Release

R2023a

Asked:

on 10 May 2023

Commented:

on 11 May 2023

Community Treasure Hunt

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

Start Hunting!