plot complex exponential fourier series

11 次查看(过去 30 天)
Hi, I'm new in MATLAB program and I need some help to solve my homework. my homework say : plot complex exponential fourier series using MATLAB where the user input the value of amplitude A, fundamental period and value of N where the summation limit between -N,N. then the program will plot curve for summation limit between -1,1. then for summation between -2,2. and increase N value to reach to summation limit between -20,20. I don't know if that right way to write code, but this is code that I wrote it, please help me.
clear
clc
A=input('Enter A: ');
T0=input('Enter T0: :');
N=input('Enter N: ');
W0= 2*pi/T0;
t=linspace(100,100,10000);
suma=0;
for n=-N:N %%n could be any number, bigger n - better approximation
B= integral(1*exp(-1i*n*W0*t),0,T0);
cn=(1/T0)*B;
suma = suma + (cn*exp(1i*n*W0*t));
end
plot(t,suma)
grid

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by