You are on page 1of 1

clear all;

close all;
syms pi
N=20;
A=5;
T=2;
wo= 2*pi/T;
dt=T/100;
t=0:dt:3*T;
ft= A*sawtooth(double(wo*(t+T/4)),0.5);
subplot(2,1,1)
plot(t,ft);
hold on;
grid on;

subplot(2,1,2)
hold on;
grid on;

a0=10;
sf=a0/2;
vbn=zeros(1,N);
for n= 1:N

an= double((128*A*sin((pi*n)/4)^4*(2*sin((pi*n)/4)^4 - 3*sin((pi*n)/4)^2 + 1))/


(pi^2*n^2));
bn=double((2*A*(sin(2*pi*n) + 2*sin((pi*n)/2) - 2*sin((3*pi*n)/2)))/
(pi^2*n^2));
sf= sf + an* cos(n*wo*t)+bn*sin(n*wo*t);
vbn(n)=bn;
subplot(2,1,1)
plot(t,sf,'color',rand(1,3))
subplot(2,1,2)
plot(t,bn*sin(n*wo*t),'color',rand(1,3))

end

figure

stem(0:N,[a0/2 abs(vbn)])
***********************************************************************************
**************

clear all;
close all;

syms t A T n
wo= 2*pi/T;
ft=(A/(T/4))* (t);
ft_1= -(A/(T/4))*( t-T/2);
ft_2=(A/(T/4))*( t-T)
An=cos (n*wo*t);
Bn=sin (n*wo*t);
aO= (2/T)*(int(ft,t,0,T/4)+ int(ft_1,t,T/4,3/4*T)+int(ft_2,t,3/4*T,T))
intBn= simplify ((2/T)*(int(ft*Bn,t,0,T/4)+ int(ft_1*Bn,t,T/4,3/4*T)
+int(ft_2*Bn,t,3/4*T,T)))
intAn= simplify ((2/T)*(int(ft*An,t,0,T/4)+ int(ft_1*An,t,T/4,3/4*T)
+int(ft_2*An,t,3/4*T,T)))

You might also like