0% found this document useful (0 votes)
42 views7 pages

% Ejercicio 1 de Matlab Series de Fourier: For End

This document contains 3 MATLAB code examples for calculating Fourier series. Each example defines a periodic function f(x) over an interval, then calculates the Fourier coefficients (ao, an, bn) by integrating f(x) against the basis functions (1, cos(wx), sin(wx)) over the interval. It expresses the Fourier series representation of f(x) in terms of these coefficients.
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)
42 views7 pages

% Ejercicio 1 de Matlab Series de Fourier: For End

This document contains 3 MATLAB code examples for calculating Fourier series. Each example defines a periodic function f(x) over an interval, then calculates the Fourier coefficients (ao, an, bn) by integrating f(x) against the basis functions (1, cos(wx), sin(wx)) over the interval. It expresses the Fourier series representation of f(x) in terms of these coefficients.
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/ 7

% EJERCICIO 1 DE MATLAB SERIES DE FOURIER

clc
syms x n
A = [ 0 pi -pi 0 ];
f = [x 0];
f = sym(f);
T = max(A)-min(A)
Wo = (2*pi/(T))
ao = 0;
for i=1:length(f)
ao= ao +int(f(i), 'x', A(i), A(i+1));
end
ao = simple(ao/T)
an =0;
for i=1:length(f)
an= an +int(f(i)*cos(wo*n*x), 'x', A(i), A(i+1));
end
an = simple(2*an/T)
bn =0;
for i=1:length(f)
bn= bn +int(f(i)*sin(wo*n*x), 'x', A(i), A(i+1));
end
bn = simple(2*bn/T)

fx = ao/2 + an*cos(wo*n*x) + bn*sin(wo*n*x)


% EJERCICIO 2 DE MATLAB DE SERIES DE FOURIER
clc
syms x n
A = [ -2 2 ];
f = [abs(x)/2];
f = sym(f);
T = max(A)-min(A)
Wo = (2*pi/(T))
ao = 0;
for i=1:length(f)
ao= ao +int(f(i), 'x', A(i), A(i+1));
end
ao = simple(ao/T)
an =0;
for i=1:length(f)
an= an +int(f(i)*cos(Wo*n*x), 'x', A(i), A(i+1));
end
an = simple(2*an/T)
bn =0;
for i=1:length(f)
bn= bn +int(f(i)*sin(Wo*n*x), 'x', A(i), A(i+1));
end
bn = simple(2*bn/T)

f(x)= ao/2 + (an*cos(Wo*n*x)) + (bn*sin(Wo*n*x))

%
EJERCICIO 3 DE MATLAB DE SERIES DE FOURIER
clc
syms x n
A = [ -2 -1 1 2 ];
f = [-x-2 x -x+2];
f = sym(f);
T = max(A)-min(A)
Wo = (2*pi/(T))
ao = 0;
for i=1:length(f)
ao= ao +int(f(i), 'x', A(i), A(i+1));
end
ao = simple(ao/T)
an =0;
for i=1:length(f)
an= an +int(f(i)*cos(Wo*n*x), 'x', A(i), A(i+1));
end
an = simple(2*an/T)
bn =0;
for i=1:length(f)
bn= bn +int(f(i)*sin(Wo*n*x), 'x', A(i), A(i+1));
end
bn = simple(2*bn/T)
f(x)= ao/2 + (an*cos(Wo*n*x)) + (bn*sin(Wo*n*x))

You might also like