How can i plot this function in matlab

1 view (last 30 days)
Yunchen Wu
Yunchen Wu on 26 Feb 2020
Commented: David Hill on 26 Feb 2020
this is a fourier transform function and how can i make it in matlab

Answers (1)

David Hill
David Hill on 26 Feb 2020
You could do something like this:
p=1:2:100000;
A=1;
T=2;
f=@(t)A/2 +2*A/pi*sum(sin(p*2*pi*t/T)./p);
t=0:.1:2;
for k=1:length(t)
F(k)=f(t(k));
end
plot(t,F);
I assume A and T are scalar.
  2 Comments
Yunchen Wu
Yunchen Wu on 26 Feb 2020
I think it basically works but why MATLAB told me error using in plot and vectors must be the same length.
David Hill
David Hill on 26 Feb 2020
Make sure you clear the variables before each use.
clear;

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!