Sei sulla pagina 1di 6

% Plot the solution of a wave equation problem in Polar Coords.

clear all
% Setup polar coordinate mesh.
[th,r] = meshgrid((0:5:360)*pi/180,0:.05:1);
% Convert to Cartesian coordinates.
[X,Y] = pol2cart(th,r);
% Then generate the complex matrix Z on the interior of the unit circle.
Z = X + i*Y;
rr = abs(Z);
% We don't need theta for this example since the solution is independent
% of theta.
% Compute alpha_n
alpha(1) = 2.4048; alpha(2) = 5.5201; alpha(3) = 8.6537;
alpha(4) = 11.7915; alpha(5) = 14.9309;
% Compute A_n and B_n matrices.
B(1)=0.642;B(2)=0.28;B(3)=0.181;B(4)=0.133;B(5)=0.105;
A = zeros(size(B));
% Other info.
N = 10;
% Number of time steps.
t = 0.00; % Step size.
for n=1:N
U=B(1)*besselj(0,2.4048*rr)*sin(2.4048*(n*t))*0.4989 + ...
B(2)*besselj(0,5.5201*rr)*sin(5.5201*(n*t))*0.4228 + ...
B(3)*besselj(0,8.65*rr)*sin(8.65*(n*t))*(-0.1804) + ...
B(4)*besselj(0,11.79*rr)*sin(11.79*(n*t))*(-0.2959) + ...
B(5)*besselj(0,14.93*rr)*sin(14.93*(n*t))*(0.1266) + ...
figure(1)
surf(X,Y,U)
axis([-1 1 -1 1 -1 1])
end
surf(X,Y,U)
xlabel('x');ylabel('y');zlabel('U');
subplot(3,2,1)
%% t=0.008
% Setup polar coordinate mesh.
[th,r] = meshgrid((0:5:360)*pi/180,0:.05:1);
% Convert to Cartesian coordinates.
[X,Y] = pol2cart(th,r);
% Then generate the complex matrix Z on the interior of the unit circle.
Z = X + i*Y;
rr = abs(Z);
% We don't need theta for this example since the solution is independent
% of theta.
% Compute alpha_n
alpha(1) = 2.4048; alpha(2) = 5.5201; alpha(3) = 8.6537;
alpha(4) = 11.7915; alpha(5) = 14.9309;
% Compute A_n and B_n matrices.
B(1)=0.642;B(2)=0.28;B(3)=0.181;B(4)=0.133;B(5)=0.105;
A = zeros(size(B));
% Other info.
N = 10;
% Number of time steps.
t = 0.008; % Step size.

for n=1:N
U=B(1)*besselj(0,2.4048*rr)*sin(2.4048*(n*t))*0.4989 + ...
B(2)*besselj(0,5.5201*rr)*sin(5.5201*(n*t))*0.4228 + ...
B(3)*besselj(0,8.65*rr)*sin(8.65*(n*t))*(-0.1804) + ...
B(4)*besselj(0,11.79*rr)*sin(11.79*(n*t))*(-0.2959) + ...
B(5)*besselj(0,14.93*rr)*sin(14.93*(n*t))*(0.1266) + ...
figure(1)
surf(X,Y,U)
axis([-1 1 -1 1 -1 1])
end
surf(X,Y,U)
xlabel('x');ylabel('y');zlabel('U');
subplot(3,2,2)
%% t=0.016
% Setup polar coordinate mesh.
[th,r] = meshgrid((0:5:360)*pi/180,0:.05:1);
% Convert to Cartesian coordinates.
[X,Y] = pol2cart(th,r);
% Then generate the complex matrix Z on the interior of the unit circle.
Z = X + i*Y;
rr = abs(Z);
% We don't need theta for this example since the solution is independent
% of theta.
% Compute alpha_n
alpha(1) = 2.4048; alpha(2) = 5.5201; alpha(3) = 8.6537;
alpha(4) = 11.7915; alpha(5) = 14.9309;
% Compute A_n and B_n matrices.
B(1)=0.642;B(2)=0.28;B(3)=0.181;B(4)=0.133;B(5)=0.105;
A = zeros(size(B));
% Other info.
N = 10;
% Number of time steps.
t = 0.016; % Step size.
for n=1:N
U=B(1)*besselj(0,2.4048*rr)*sin(2.4048*(n*t))*0.4989 + ...
B(2)*besselj(0,5.5201*rr)*sin(5.5201*(n*t))*0.4228 + ...
B(3)*besselj(0,8.65*rr)*sin(8.65*(n*t))*(-0.1804) + ...
B(4)*besselj(0,11.79*rr)*sin(11.79*(n*t))*(-0.2959) + ...
B(5)*besselj(0,14.93*rr)*sin(14.93*(n*t))*(0.1266) + ...
figure(1)
surf(X,Y,U)
axis([-1 1 -1 1 -1 1])
end
surf(X,Y,U)
xlabel('x');ylabel('y');zlabel('U');
subplot(3,2,3)
%% t=0.024
% Setup polar coordinate mesh.
[th,r] = meshgrid((0:5:360)*pi/180,0:.05:1);
% Convert to Cartesian coordinates.
[X,Y] = pol2cart(th,r);
% Then generate the complex matrix Z on the interior of the unit circle.
Z = X + i*Y;
rr = abs(Z);
% We don't need theta for this example since the solution is independent
% of theta.

% Compute alpha_n
alpha(1) = 2.4048; alpha(2) = 5.5201; alpha(3) = 8.6537;
alpha(4) = 11.7915; alpha(5) = 14.9309;
% Compute A_n and B_n matrices.
B(1)=0.642;B(2)=0.28;B(3)=0.181;B(4)=0.133;B(5)=0.105;
A = zeros(size(B));
% Other info.
N = 10;
% Number of time steps.
t = 0.024; % Step size.
for n=1:N
U=B(1)*besselj(0,2.4048*rr)*sin(2.4048*(n*t))*0.4989 + ...
B(2)*besselj(0,5.5201*rr)*sin(5.5201*(n*t))*0.4228 + ...
B(3)*besselj(0,8.65*rr)*sin(8.65*(n*t))*(-0.1804) + ...
B(4)*besselj(0,11.79*rr)*sin(11.79*(n*t))*(-0.2959) + ...
B(5)*besselj(0,14.93*rr)*sin(14.93*(n*t))*(0.1266) + ...
figure(1)
surf(X,Y,U)
axis([-1 1 -1 1 -1 1])
end
surf(X,Y,U)
xlabel('x');ylabel('y');zlabel('U');
subplot(3,2,4)
%% t=0.032
% Setup polar coordinate mesh.
[th,r] = meshgrid((0:5:360)*pi/180,0:.05:1);
% Convert to Cartesian coordinates.
[X,Y] = pol2cart(th,r);
% Then generate the complex matrix Z on the interior of the unit circle.
Z = X + i*Y;
rr = abs(Z);
% We don't need theta for this example since the solution is independent
% of theta.
% Compute alpha_n
alpha(1) = 2.4048; alpha(2) = 5.5201; alpha(3) = 8.6537;
alpha(4) = 11.7915; alpha(5) = 14.9309;
% Compute A_n and B_n matrices.
B(1)=0.642;B(2)=0.28;B(3)=0.181;B(4)=0.133;B(5)=0.105;
A = zeros(size(B));
% Other info.
N = 10;
% Number of time steps.
t = 0.032; % Step size.
for n=1:N
U=B(1)*besselj(0,2.4048*rr)*sin(2.4048*(n*t))*0.4989 + ...
B(2)*besselj(0,5.5201*rr)*sin(5.5201*(n*t))*0.4228 + ...
B(3)*besselj(0,8.65*rr)*sin(8.65*(n*t))*(-0.1804) + ...
B(4)*besselj(0,11.79*rr)*sin(11.79*(n*t))*(-0.2959) + ...
B(5)*besselj(0,14.93*rr)*sin(14.93*(n*t))*(0.1266) + ...
figure(1)
surf(X,Y,U)
axis([-1 1 -1 1 -1 1])
end
surf(X,Y,U)
xlabel('x');ylabel('y');zlabel('U');
subplot(3,2,5)

%% t=0.04
% Setup polar coordinate mesh.
[th,r] = meshgrid((0:5:360)*pi/180,0:.05:1);
% Convert to Cartesian coordinates.
[X,Y] = pol2cart(th,r);
% Then generate the complex matrix Z on the interior of the unit circle.
Z = X + i*Y;
rr = abs(Z);
% We don't need theta for this example since the solution is independent
% of theta.
% Compute alpha_n
alpha(1) = 2.4048; alpha(2) = 5.5201; alpha(3) = 8.6537;
alpha(4) = 11.7915; alpha(5) = 14.9309;
% Compute A_n and B_n matrices.
B(1)=0.642;B(2)=0.28;B(3)=0.181;B(4)=0.133;B(5)=0.105;
A = zeros(size(B));
% Other info.
N = 10;
% Number of time steps.
t = 0.1; % Step size.
for n=1:N
U=B(1)*besselj(0,2.4048*rr)*sin(2.4048*(n*t))*0.4989 + ...
B(2)*besselj(0,5.5201*rr)*sin(5.5201*(n*t))*0.4228 + ...
B(3)*besselj(0,8.65*rr)*sin(8.65*(n*t))*(-0.1804) + ...
B(4)*besselj(0,11.79*rr)*sin(11.79*(n*t))*(-0.2959) + ...
B(5)*besselj(0,14.93*rr)*sin(14.93*(n*t))*(0.1266) + ...
figure(1)
surf(X,Y,U)
axis([-1 1 -1 1 -1 1])
end
surf(X,Y,U)
xlabel('x');ylabel('y');zlabel('U');
subplot(3,2,6)

Potrebbero piacerti anche