0% found this document useful (0 votes)
31 views5 pages

Serie de Fourier Parte II: %% Grafica de Funcion Periodica

This document discusses the Fourier series representation of periodic functions. It begins by graphing an example periodic function made up of several piecewise linear segments. It then calculates the Fourier coefficients (a0, an, bn) of the periodic function by integrating over each period. Finally, it plots the original periodic function alongside the Fourier series approximation using the first 20 harmonics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views5 pages

Serie de Fourier Parte II: %% Grafica de Funcion Periodica

This document discusses the Fourier series representation of periodic functions. It begins by graphing an example periodic function made up of several piecewise linear segments. It then calculates the Fourier coefficients (a0, an, bn) of the periodic function by integrating over each period. Finally, it plots the original periodic function alongside the Fourier series approximation using the first 20 harmonics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Serie de Fourier parte II

%% grafica de funcion periodica


clc
clear all
close all
t=0:0.01:12;
f1=(-2*t+4).*(t>=0&t<=2);
f2=(2*t-4).*(t>2&t<=4);
f3=(-2*t+12).*(t>4&t<=6);
f4=(2*t-12).*(t>6&t<=8);
f5=(-2*t+20).*(t>8&t<=10);
f6=(2*t-20).*(t>10&t<=12);
ft=f1+f2+f3+f4+f5+f6;
plot(t,ft,'r');
title('funcion periodica T=4');
xlabel('t');
ylabel('f(t)');
grid on;
%% serie de fourier
clc
clear all
close all
syms n t
%intervalo
d=[0 2 4];
nd=length(d);
%numero de intervalos
ni=nd-1;
%periodo
T=d(nd)-d(1);
%frecuencia
fr=1/T;
%frecuencia angular
w=2*pi*fr;
%funcion periodica
f=[-2*t+4 , 2*t-4];
f=sym(f);
%calculo de a0
suma=0;
for k=1:ni
suma=suma+int(f(k),'t',d(k),d(k+1));
end
a0=suma/T;
%calculo de an
suma=0;
for k=1:ni
suma=suma+int(f(k)*cos(n*w*t),'t',d(k),d(k+1));
end
an1=2*suma/T;
an=simplify(an1);

%calculo de bn
suma=0;
for k=1:ni
suma=suma+int(f(k)*sin(n*w*t),'t',d(k),d(k+1));
end
bn1=2*suma/T;
bn=simplify(bn1);

%%
clc
clear all
close all
t=0:0.01:4;
f1=(-2*t+4).*(t>=0&t<=2);
f2=(2*t-4).*(t>2&t<=4);
ft=f1+f2;
%intervalo
d=[0 2 4];
nd=length(d);
%numero de intervalos
ni=nd-1;
%periodo
T=d(nd)-d(1);
%frecuencia
fr=1/T;
%frecuencia angular
w=2*pi*fr;
plot(t,ft,'r');
title('funcion periodica T=4');
xlabel('t');
ylabel('f(t)');
grid on
hold on

a0=2;
suma=0;
%numero de armonicos
narm=20;
for n=1:narm
a(n)=(8*cos(pi*n)*(cos(pi*n) + pi*n*sin(pi*n) - 1))/(pi^2*n^2);
b(n)=-(8*(cos(pi*n) - 1)*(pi*n - sin(pi*n) +
pi*n*cos(pi*n)))/(pi^2*n^2);
suma = suma +a(n).*cos(n*w*t)+b(n).*sin(n*w*t);
end
ff=a0+suma;
plot(t,ff,'b');
1

You might also like