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);
ao=integral(f,-pi,pi)./pi; figure();
f1=@(x)f(x).*cos(n.*x); S=@(t)ao./2+0.*t;
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
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
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
A(:,n)=[(cos((n./2).*x))']; a0=integral(f,-pi,pi)./pi;
end a(n)=integral(f1,-pi,pi)./pi;
Z=inv(A)*F; b(n)=integral(g1,-pi,pi)./pi;
ao=[Z(1)]; end
if rem(n,2)==0 F=f(x);
a(n./2)=[Z(n)]; figure();
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);
end
function [U] =
VibracionOnda2D(f,g,L,D,a,N,M)
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];