Quick Question - Wave Equation - what does N do?
Show older comments
Hi,
I am a fairly new user of MATLAB and need a quick bit of help. I have been given some code(located below) and been asked to discover what N does. The values for N that I have are 5, 10 and 50. Can anyone please explain what this value represents.
Thankyou in advance
% initialise constants
L=3; mu=1; N=5; b=21/11; c=10;
% set up x-vector for plots
x = L*linspace(0,1,500);
% set up limits for x and y axes
v = [0 L -1.1*mu 1.1*mu];
% set up value for time step T
% T is the period of oscillation divided by 15
T = 2/75;
% set up for loop for incrementing t in 16
% equal steps of length T
for m = 1:16
t = (m-1)*T;
% initialise u to be zero then sum first N terms
u = 0;
for n = 1:N
u = u+2*mu*L^2/(pi^2*b*(L-b)*n^2)*sin(n*pi*b/L)*sin(n*pi*x/L)*cos(n*pi*c*t/L);
end
% plot this sum and store for movie using getframe
figure(1),plot(x,u),axis(v)
M(m) = getframe;
%replot in a 4X4 array for displaying frames
figure(2),subplot(4,4,m),plot(x,u),axis(v)
end
% show movie with 10 periods
firgure(1),movie(M(1:15),10)
% display the individual frames
figure(2)
2 Comments
Muthu Annamalai
on 27 Feb 2013
It seems like you are plotting the Fourier Series solutions of the particular PDE, and you are calculating the first N modes as I figure from the comments.
I recommend you play with the script by plotting the charts for various N = 4:10:50 and see the resolution / detail in the wave functions (solutions to your original wave equation)
Benjamin Rodgers
on 27 Feb 2013
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!