Vous êtes sur la page 1sur 4

function [s] =SumaParcialFourier(f,N)

%UNTITLED Summary of this function goes here


%
Detailed explanation goes here
a0=integral(f,-pi,pi)./pi;
for n=1:N
f1=@(x) f(x).*cos(n.*x);
f2=@(x) f(x).*sin(n.*x);
a(n)=integral(f1,-pi,pi)./pi;
b(n)=integral(f2,-pi,pi)./pi;
end
s=@(x) a0./2+0.*x;
for n=1:N
s=@(x) s(x)+a(n).*cos(n.*x)+b(n).*sin(n.*x);
end
x=[-pi:0.001:pi];
s1=s(x); h1=f(x);
figure(), plot(x,s1,'r'),
hold on, grid on, plot(x,h1,'b');
end

function [R]=BesselRaices(p,M,epsi)
x=[0:0.1:(pi.*M).*2];
L=length(x); r=0;
for l=1:L-1
if besselj(p,x(l)).*besselj(p,x(l+1))<0
r=r+1;
A(r)=[x(l)]; B(r)=[x(l+1)];
end
end
for m=1:M
iz=A(m); de=B(m);
while(de-iz)>epsi;
med=(de+iz)./2;
if besselj(p,iz).*besselj(p,med)<0
de=med;
else
iz=med;
end
end
R(m)=med;
end
%Programa para encontrar races
%usando la ecuacion de bessel
%ao/2+ sumatoria anCos(nx)+bnSin(nx)
end

function [u] =OndaHomogenea(f,g,a,L,N)


%Cuerda
for n=1:N
f1=@(x) f(x).*sin(n.*pi.*x./L);
A(n)=integral(f1,0,L).*2./L;
g1=@(x) g(x).*sin(n.*pi.*x./L);
B(n)=2.*integral(g1,0,L)./(n.*pi.*a);
end
u=@(x,t) 0.*x+0.*t;
for n=1:N
u=@(x,t) u(x,t)+(A(n).*cos(a.*n.*pi.*t./L)+
B(n).*sin(a.*n.*pi.*t./L)).*sin(n.*pi.*x./L);
end
x=[0:0.1:L]; t=[0:1:1000];
M=length(t);
for m=1:M
u1=u(x,t(m));
plot(x,u1,'r','LineWidth',5),
hold on, grid on, hold off,axis([0 L -1 1])
pause(0.1)
end
end

function [w] =VibracionTamborCircular(f,g,a,L,N,M,epsi)


%UNTITLED2 Summary of this function goes here
%
Detailed explanation goes here
[R]=RaicesBessel(0,M,epsi);
[Ra]=RaicesBesselMatriz(N,M,epsi);
[u,A0,A,C]=FourierBessel2d(f,L,N,M,epsi);
w=@(fi,r,t) r.*0+fi.*0+t.*0;
for m=1:M
w=@(fi,r,t) w(fi,r,t)+A0(m).*cos(a.*R(m).*t./L)
.*besselj(0,R(m).*r./L);
end
w=@(r,fi,t) w(r,fi,t).*2;
for n=1:N
for m=1:M
w=@(fi,r,t) w(r,fi,t)+A(n,m)
.*cos(a.*Ra(n,m).*t./L)
.*besselj(n,Ra(n,m).*r./L).*cos(fi.*n);
w=@(fi,r,t) w(r,fi,t)+C(n,m)
.*cos(a.*Ra(n,m).*t./L)
.*besselj(n,Ra(n,m).*r./L).*sin(fi.*n);
end
end
s=[0:0.1:L]; Fi=[0:0.01:2.*pi];
[Fi,s]=meshgrid(Fi,s);
[Fi,s]=pol2cart(Fi,s);
t=[0:1:300]; T=length(t);
for n=1:T
w1=w(Fi,s,t(n));
surf(Fi,s,w1);hold on, grid on,
axis([-2.*pi,2.*pi,-2.*L,2.*L,-1,1]),view(3),;
pause(0.5)
hold off;
end
end

function [u] = MembranaVibrante(f,g,a,L1,L2,N,M)


%UNTITLED3 Summary of this function goes here
%
Detailed explanation goes here
for n=1:N
for m=1:M
f1=@(x,y) f(x,y).*sin(n.*pi.*x./L1)
.*sin(m.*pi.*y./L2);
g1=@(x,y) g(x,y).*sin(n.*pi.*x./L1)
.*sin(m.*pi.*y./L2);
A(n,m)=4.*integral2(f1,0,L1,0,L2)./(L1.*L2);
B(n,m)=4.*integral2(g1,0,L1,0,L2)./(L1.*L2);
D=a.*sqrt((n./L1).^2+(m./L2).^2).*pi;
B(n,m)=B(n,m)./D;
end
end
u=@(x,y,t) 0.*x+0.*y+0.*t;
for n=1:N
for m=1:M
D=a.*sqrt((n./L1).^2+(m./L2).^2).*pi;
u=@(x,y,t) u(x,y,t)+
(A(n,m).*cos(D.*t)+B(n,m)
.*sin(D.*t)).*sin(n.*x.*pi./L1)
.*sin(m.*y.*pi./L2);
end
end
x=[0:0.2:A];
y=[0:0.2:B];
[x,y]=meshgrid(x,y);
t=[0:0.1:100];
T=length(t);
figure()
for r=1:T
u1=u(x,y,t(r));
surf(x,y,u1),hold on, grid on;
pause(0.05)
hold off
end
end

Vous aimerez peut-être aussi