Fourier series representation of ramp Input
clear all;
close all;
clc;
T=input('Enter the time period');
syms t
pi=3.14;
w=(2*pi)/T; sum=0;
x=t; %input signal
ao=(1/T)*int(x,t,-T/2,T/2);
%finding the coefficients
for n=1:11
an=(2/T)*int(x*cos(n*w*t),t,-T/2,T/2);
bn=(2/T)*int(x*sin(n*w*t),t,-T/2,T/2);
sum=sum+(an*cos(n*w*t)+bn*sin(n*w*t));
end
fplot(t,x,[-T/2,T/2]);
grid on; hold on;
fplot(t,(sum+ao),[-T/2,T/2]);
xlabel('t');
ylabel('Amplitude');
title('input signal and its Fourier Series representation');
legend('input', 'Fourier series')
Fourier series representation of exponential Input
clear all;
close all;
clc;
T=input('Enter the time period');
syms t
pi=3.14;
w=(2*pi)/T;
sum=0;
x=exp(t); %input signal
ao=(1/T)*int(x,t,-T/2,T/2);
%finding the coefficients
for n=1:11
an=(2/T)*int(x*cos(n*w*t),t,-T/2,T/2);
bn=(2/T)*int(x*sin(n*w*t),t,-T/2,T/2);
sum=sum+(an*cos(n*w*t)+bn*sin(n*w*t));
end
fplot(t,x,[-T/2,T/2]);
grid on;
hold on;
fplot(t,(sum+ao),[-T/2,T/2]);
xlabel('t');
ylabel('Amplitude');
title('input signal and its Fourier Series representation');
legend('input','Fourier series')