Function: 'R' 'Linewidth' On On 'B' 'Linewidth' Off

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

SUMAPARCIALFOURIER

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;
x=[-pi:0.01:pi];
F=f(x);
S1=S(x);
figure(),plot(x,F,'r','LineWidth',3),hold on,grid on,plot(x,S1,'b','LineWidth',2);
pause(1);
hold off;
for n=1:N
S=@(x) S(x)+a(n).*cos(n.*x)+b(n).*sin(n.*x);
S1=S(x);
plot(x,F,'r','LineWidth',3),hold on,grid on,plot(x,S1,'b','LineWidth',2);
pause(1);
hold off;
end
plot(x,F,'r','LineWidth',3),hold on,grid on,plot(x,S1,'b','LineWidth',2);
end
SISTEMAFOURIER
function [S] = FourierSistema(f,T,N)
%UNTITLED Summary of this function goes here
%
Detailed explanation goes here
p=2.*T./(2.*N+1);
x=[-T:p:T-p];
F=[f(x)]';
A=zeros(2.*N+1,2.*N+1);
A(:,1)=[ones(2.*N+1,1)./2];
for n=2:2.*N+1
if rem(n,2)==0
A(:,n)=[cos(n.*x.*pi./(2.*T))]';
else
A(:,n)=[sin((n-1).*x.*pi./(2.*T))]';
end
end
D=inv(A)*F;
S=@(x) D(1)./2+0.*x;
for n=2:2:2.*N
S=@(x) S(x)+D(n).*cos(n.*x.*pi./(2.*T))+D(n+1).*sin(n.*x.*pi./(2.*T));
end
u=[-T:0.001:T];
G=f(u);S1=S(u);
figure(), plot(u,G,'r'),hold on,grid on,plot(u,S1,'b');
end

FOURIER2
function [S] = EdisonFourier2(f,T,N)
%UNTITLED2 Summary of this function goes here
%
Detailed explanation goes here

p=(2.*T)./(2.*N+1);
x=[-T:p:T-p];
F=(f(x))';
A=zeros(2.*N+1,2.*N+1);
A(:,1)=[ones(2.*N+1,1)./2];
for n=2:2:(2.*N)
A(:,n)=(cos((n./2).*x.*pi./T))';
A(:,n+1)=(sin((n./2).*x.*pi./T))';
end
D=inv(A)*F;
S=@(x) D(1)./2+0*x;
for n=2:2:(2.*N)
S=@(x) S(x)+D(n).*cos(n.*x.*pi./(T.*2))+D(n+1).*sin(n.*x.*pi./(T.*2));
end
u=[-T:.01:T];
fi=f(u);
S1=S(u);
figure(),plot(u,fi,'r','LineWidth',2),hold on, grid on,plot(u,S1,'b','LineWidth',2);

end

FOURIER
function [S] = EdisonFourier(f,N)
%UNTITLED2 Summary of this function goes here
%
Detailed explanation goes here

p=(2.*pi)./(2.*N+1);
x=[-pi:p:pi-p];
F=(f(x))';
A=zeros(2.*N+1,2.*N+1);
A(:,1)=[ones(2.*N+1,1)./2];
for n=2:2:(2.*N)
A(:,n)=(cos((n./2).*x))';
A(:,n+1)=(sin((n./2).*x))';
end
D=inv(A)*F;
S=@(x) D(1)./2+0*x;
for n=2:2:(2.*N)
S=@(x) S(x)+D(n).*cos(n.*x./2)+D(n+1).*sin(n.*x./2);
end
u=[-pi:.01:pi];

fi=f(u);
S1=S(u);
figure(),plot(u,fi,'r','LineWidth',2),hold on, grid on,plot(u,S1,'b','LineWidth',2);

end

VIBRACIONESTAMBORRECTANGULAR
function [U] = VibracionesTamborRectangular(f,g,a,A,B,N,M)
%UNTITLED 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./A).*sin(m.*pi.*y./B);
g1=@(x,y) g(x,y).*sin(n.*pi.*x./A).*sin(m.*pi.*y./B);
L(n,m)=4.*integral2(f1,0,A,0,B)./(A.*B);
F(n,m)=4.*integral2(g1,0,A,0,B)./(A.*B);
D=a.*sqrt((n./A).^2+(m./B).^2).*pi;
F(n,m)=F(n,m)./D;
end
end
U=@(x,y,t) 0.*x+0.*y+0.*t;
for n=1:N
for m=1:M
S=sqrt((n./A).^2+(m./B).^2).*pi;
U=@(x,y,t) U(x,y,t)+(L(n,m).*cos(a.*S.*t)+F(n,m).*sin(a.*S.*t)).*sin(n.*pi.*x./A).*sin(m.*pi.*y./B);
end
end
x=[0:0.1:A]; y=[0:0.1:B];
[x,y]=meshgrid(x,y);
t=[0:1:200]; T=length(t);
figure();
for r=1:T
U1=U(x,y,t(r));
surf(x,y,U1),hold on,grid on;
pause(0.2);
hold off;
end
end

RUSSELCUERDA
function [ U ] = RussellCuerda(a,L,f,g,N )
for n=1:N
f1=@(x) f(x).*sin (n.*pi.*x./L);
A(n)= 2.*integral(f1,0,L);
g1=@(x) g(x).*sin (n.*pi.*x./L);
B(n)=(2./(a.*pi.*n)).*integral(g1,0,L);
end
U=@(x,t) 0.*x +0.*t;
for n=1:N
U=@(x,t) U(x,t) + A(n).*sin(n.*pi.*x./L).*cos(a.*n.*pi.*t./L) +B(n).*sin(n.*pi.*x./L).*sin(a.*n.*pi.*t./L);
end
x=[0:0.1:L];
t=[0:0.5:1000];
T=length(t);
figure();
for m=1:T
u1=U(x,t(m));
plot(x,u1,'r','LineWidth',2),hold on,grid on, axis([0 L -L L]);
pause(0.01);
hold off;
end

end

CALOR
function [U] = CalorCarlos(a,L,f,N)
%UNTITLED Summary of this function goes here
%
Detailed explanation goes here
for n=1:N
f1=@(x) f(x).*sin(n.*pi.*x./L);
A(n)= integral(f1,0,L).*2./L;
end
U= @(x,t) 0.*x+0.*t;
for n=1:N
D=(a.*pi.*n./L).^2;
U= @(x,t) U(x,t)+A(n).*exp(-D.*t).*sin(n.*pi.*x./L);
end
x=[0:0.01:L];
t=[0:0.1:100];
T=length(t);
figure();
for r=1:T
U1=U(x,t(r));
plot(x,U1,'r','LineWidth',2),hold on,grid on;
pause(0.1);
hold off;
end
end

MEMBRANA VIBRANTE
function [U] = MembranaVibranteLucas(a,L,H,f,g,N,M)
%UNTITLED 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(pi.*n.*x./L).*sin(pi.*m.*y./H);
g1=@(x,y) g(x,y).*sin(pi.*n.*x./L).*sin(pi.*m.*y./H);
A(n,m)=4.*integral2(f1,2,2.5,1.5,2)./(L.*H);
B(n,m)=4.*integral2(g1,0,L,0,H)./(L.*H);
D=a.*sqrt((n./L).^2+(m./H).^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./L)^2)+((m./H).^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./L).*sin(m.*y.*pi./H);
end
end
U=@(x,y,t) U(x,y,t).*exp(-t);
x=[0:0.1:L];
y=[0:0.1:H];
t=[0:0.01:100];
[x,y]=meshgrid(x,y);
T=length(t);
figure();
for r=1:T
U1=U(x,y,t(r));
mesh(x,y,U1), hold on, grid on,axis([0 L 0 H -.1 .1]);
pause(0.05);
hold off;
end
end
BESSELPRAICES
f=@(x) besselj(pi,x);
x=[0:0.1:1000]; N=length(x);
m=0;
for n=1:N-1
if (f(x(n)).*f(x(n+1))<0)==1
m=m+1;
Z(m)=[(x(n)+x(n+1))./2];
end
end
M=length(Z);
for m=1:M
R(m)=fzero(f,Z(m));
end

FUNCIONBESSEL
function [S] = BesselTamayo(g,p,N,L)
f=@(x) besselj(p,x);
x=[0:0.1:2.*N.*pi];
M=length(x);
m=0;
for n=1:M-1
if ((f(x(n)).*f(x(n+1))<0)==1)
m=m+1;
v=(x(n)+x(n+1))./2;
R(m)=fzero(f,v);
end
end
for n=1:N
g1=@(u) u.*g(u).*f(R(n).*u./L);
C(n)=2.*integral(g1,0,L)./(L.*besselj(p+1,R(n))).^2;
end
W=[0:0.01:L];
gv=g(W);
figure();
S=@(u) 0.*u;
for n=1:N
S=@(u) S(u)+C(n).*f(R(n).*u./L);
S1=S(W);
plot(W,gv,'b','LineWidth',2), hold on, grid on, plot(W,S1,'r','LineWidth',2);
pause(0.1);
hold off;
end

end

SERIEFOURIERBESSEL
g=@(u) exp(sin(u));
BesselPiRaices;
L=10;
for m=1:M
d=@(u) u.*g(u).*f(R(m).*u./L);
C(m)=2.*integral(d,0,L)./(besselj(pi+1,R(m))).^2;
C(m)=C(m)./L.^2;

end
k=@(u) 0.*u;
for m=1:M
k=@(u) k(u)+C(m).*f(R(m).*u./L);
end
u=[0:0.001:L];
k1=k(u); l1=g(u);
figure(),plot(u,k1,'r','LineWidth',2),hold on,grid on,plot(u,l1,'b','LineWidth',2);

You might also like