Anda di halaman 1dari 5

f=@(x) (cos(exp(x)));

Ao= integral(f,-pi,pi)./pi; function [ S ] = DesarrolloSerieFourier(


f,N )
for n=1:50
%UNTITLED5 Summary of this function
f1=@(x) f(x).*cos(n.*x);
goes here
f2=@(x) f(x).*sin(n.*x);
% Detailed explanation goes here

ao=integral(f,-pi,pi)./pi;
A(n)= integral(f1,-pi,pi)./pi;
for n=1:N
B(n)= integral(f2,-pi,pi)./pi;
f1=@(x)f(x).*cos(n.*x);
end
f2=@(x)f(x).*sin(n.*x);
ao=(2./5).*(6-(Ao./2));
a(n)=integral(f1,-pi,pi)./pi;
for n=1:50
b(n)=integral(f2,-pi,pi)./pi;
F=[-(3.*n.^2+5) 4.*n; -4.*n -(3.*n.^2+5)];
end
D=[A(n);B(n)];
x=[-pi:0.01:pi];
Z=inv(F)*D;
figure();
a(n)=Z(1);b(n)=Z(2);
F=f(x);
end
S=@(x)ao./2+0.*x;
Y=@(x) ao./2+0.*x;
plot(x,F,'r','LineWidth',2),hold on, grid on,
for n=1:50 plot(x,S(x),'b','LineWidth',2);

Y=@(x) pause(0.001);
Y(x)+a(n).*cos(n.*x)+b(n).*sin(n.*x);
hold off;
end
for n=1:N

S=@(x)
h=0.0001; S(x)+a(n).*cos(n.*x)+b(n).*sin(n.*x);

dY=@(x) (Y(x+h)-Y(x))./h; plot(x,F,'r','LineWidth',2), hold on, grid


on, plot(x, S(x),'b','LineWidth',2);
ddY=@(x) (dY(x+h)-dY(x))./h;
pause(0.1);
g=@(x) 3.*ddY(x)+4.*dY(x)-5.*Y(x)+6-f(x);
hold off;
x=[0:0.01:pi];
end
g1=g(x);
end
figure();
function [ S ] = DesarrolloSerieFourier2(
plot(x,g1,'r','LineWidth',2),hold on, grid on; f,N )

%UNTITLED5 Summary of this function


goes here
% Detailed explanation goes here t=[-T:0.01:T];

ao=integral(f,-pi,pi)./pi; figure();

for n=1:N F=f(t);

f1=@(x)f(x).*cos(n.*x); S=@(t)ao./2+0.*t;

f2=@(x)f(x).*sin(n.*x); for n=1:N

a(n)=integral(f1,-pi,pi)./pi; S=@(t)
S(t)+a(n).*cos(n.*((pi./T).*t))+b(n).*sin(n.*(
b(n)=integral(f2,-pi,pi)./pi;
(pi./T).*t));
end
end
x=[-2.*pi:0.01:2.*pi];
S1=S(t);
figure();
plot(t,S1,'r','linewidth',2), hold on, grid on,
F=f(x); plot(t,F, 'b');

S=@(x)ao./2+0.*x; end

for n=1:N function [ U ] = EcuacionDeCalor1D( a,L,f,N


)
S=@(x)
S(x)+a(n).*cos(n.*x)+b(n).*sin(n.*x); %UNTITLED11 Summary of this function
goes here
end
% Detailed explanation goes here
S1=S(x);
for n=1:N
plot(x,S1,'r','linewidth',2), hold on, grid on,
plot(x,F, 'b'); f1=@(x) f(x).*sin(n.*pi.*x./L);

end C(n)= 2.*integral(f1,0,L)./L;

function [ S ] = DesarrolloSerieFourier3( end


f,T,N )
U=@(x,t) 0.*x+0.*t;
%UNTITLED5 Summary of this function
for n=1:N
goes here
U=@(x,t) U(x,t)+C(n).*(exp(-
% Detailed explanation goes here
(a.*n.*pi./L).^2.*t)).*sin(n.*pi.*x./L);
ao=integral(f,-T,T)./T;
end
for n=1:N
x=[0:0.01:L];
f1=@(t)f(t).*cos(n.*((pi./T).*t));
t=[0:0.01:15]; M=length(t);
f2=@(t)f(t).*sin(n.*((pi./T).*t));
figure();
a(n)=integral(f1,-T,T)./T;
for m=1:M
b(n)=integral(f2,-T,T)./T;
U1=U(x,t(m));
end
plot(x,U1,'r','LineWidth',2),hold on, grid
on; axis([0 L 0 100]);
pause(0.5); mesh(X,Y,U1), hold on, grid on; axis ([0 L
0 D 0 120]);
hold off;
pause(0.5);
end

end
function [ U ] = EcuacionOnda1D( L,a,f,g,N)
function [ U ] = EcuacionDeCalor2D(
L,D,f,N,M,a) %UNTITLED4 Summary of this function
goes here
%UNTITLED4 Summary of this function
goes here % Detailed explanation goes here

% Detailed explanation goes here for n=1:N

for n=1:N f1=@(x)f(x).*sin(n.*pi.*x./L);

for m=1:M C(n)=2.*integral(f1,0,L)./L;

f1=@(x,y) g1=@(x)g(x).*sin(n.*pi.*x./L);
f(x,y).*sin(n.*pi.*x./L).*sin(m.*pi.*y./D);
D(n)=2.*integral(g1,0,L)./L;
C(n,m)=4./(L.*D).*integral2(f1,0,L,0,D);
D(n)=L.*D(n)./(a.*n.*pi);
end
end
end
U=@(x,t) 0.*x + 0.*t;
U=@(x,y,t) 0.*x+0.*y+0.*t;
for n=1:N
for n=1:N
U=@(x,t)
for m=1:M U(x,t)+(C(n).*cos(n.*pi.*a.*t./L)+D(n).*sin(
n.*pi.*a.*t./L)).*sin(n.*pi.*x./L);
b=-
(a.^2).*(((n.^2).*(pi.^2)./(L.^2))+((m.^2).*( end
pi.^2)./(D.^2)));
x=[0:0.01:L];
U=@(x,y,t)
t=[0:0.1:100]; M=length(t);
U(x,y,t)+C(n,m).*exp(b.*t).*sin((n.*pi./L).*x
).*sin((m.*pi./D).*y); figure();
end for m=1:M
end U1=U(x,t(m));
x=[0:0.1:L]; plot(x,U1,'LineWidth',2), hold on, grid
on, axis([0 L -0.001 0.001]);
y=[0:0.1:D];
pause(0.05);
[X,Y]=meshgrid(x,y);
hold off;
t=[0:0.1:20]; T=length(t);
end
figure()
end
for s=1:T

U1=U(X,Y,t(s));
function [ ao,a,b,S ] = FourierMatrices( f,N f1=f(u);
)
S1=S(u);
%UNTITLED2 Summary of this function
figure(), plot(u,f1,'r'), hold on, grid on,
goes here
plot(u,S1,'b');
% Detailed explanation goes here

P=(2.*pi)./(2.*N+1);

x=[-pi:P:pi-P];

F=f(x)';
end
A=zeros(2.*N+1,2.*N+1);
function [S] = Prueba(f,N)
A(:,1)=[1./2];
%UNTITLED Summary of this function goes
for n=2:2.*N+1 here

if rem(n,2)==0 % Detailed explanation goes here

A(:,n)=[(cos((n./2).*x))']; a0=integral(f,-pi,pi)./pi;

else for n=1:N

A(:,n)=[(sin(((n-1)./2).*x))']; f1=@(x) f(x).*cos(n.*x);

end g1=@(x) f(x).*sin(n.*x);

end a(n)=integral(f1,-pi,pi)./pi;

Z=inv(A)*F; b(n)=integral(g1,-pi,pi)./pi;

ao=[Z(1)]; end

for n=2:2.*N+1 x=[-pi:0.001:pi];

if rem(n,2)==0 F=f(x);

a(n./2)=[Z(n)]; figure();

else S=@(x) a0./2+0.*x;

b((n-1)./2)=[Z(n)]; for n=1:N

end

end S=@(x)
S(x)+a(n).*cos(n.*x)+b(n).*sin(n.*x);
S=@(x) Z(1)./2+0.*x;
S1=S(x);
for n=2:2:2.*N
plot(x,F,'r','LineWidth',3),hold on,grid on;
S=@(x) S(x)+
Z(n).*cos((n./2).*x)+Z(n+1).*sin((n./2).*x); plot(x,S1,'b');

end pause(1);

u=[-pi:0.01:pi]; hold off;


end

end

function [U] =
VibracionOnda2D(f,g,L,D,a,N,M)

%UNTITLED3 Summary of this function


goes here

% Detailed explanation goes here

C=zeros(N,M);

F=zeros(N,M);

for n=1:N

for m=1:M

f1=@(x,y)
f(x,y).*sin(n.*pi.*x./L).*sin(m.*pi.*y./D);

g1=@(x,y)
g(x,y).*sin(n.*pi.*x./L).*sin(m.*pi.*y./D);

C(n,m)=4.*integral2(f1,0,L,0,D)./(L.*D);

F(n,m)=4.*integral2(g1,0,L,0,D)./(L.*D);

W=a.*pi.*sqrt(n.^2./L.^2+m.^2./D.^2);

F(n,m)=F(n,m)./W;

end

end

U=@(x,y,t) 0.*x+0.*y+0.*t;

for n=1:N

for m=1:M

W=a.*pi.*sqrt(n.^2./L.^2+m.^2./D.^2);

U=@(x,y,t)
U(x,y,t)+(C(n,m).*cos(W.*t)+F(n,m).*sin(W.
*t)).*sin(n.*pi.*x./L).*(sin(m.*pi.*y./D));

end

end

x=[0:0.1:L];

Anda mungkin juga menyukai