Code covered by the BSD License
-
analyseExperimentalData(inFil...
analyseExperimentalData :
-
comparePendulumToSHM(x0,k,m)
comparePendulumToSHM : compare the motion of a simple harmonic oscillator
-
makeSincMovie
Copyright 2008-2009 The MathWorks, Inc.
-
pendulumDE(tVals,omega0,start...
Copyright 2008-2009 The MathWorks, Inc.
-
pendulumDataSimulated(x0, pen...
Generate simulated pendulum data and write this to an Excel spreadsheet.
-
pendulumFitFunction(t,y,param...
pendulumFitFunction : returns the fit value of pendulum model to
-
pendulumSimulation(x0,g,len)
pendulumSimulation : Simulation of pendulum
-
plotFrequencySpectrum(sampleF...
Plot the frequency spectrum of simple harmonic motion
-
plotTimeSeries(res)
Plot the time series representation of simple harmonic motion
-
readExperimentalData(inFileNa...
readExperimentalData : Read in the pendulum experiment data from an Excel
-
shmDataSimulated(x0, springCo...
Generate simulated pendulum data
-
shmSimulation(x0,k,m)
Simulation of SHM with spring constant k and mass m
-
lecture_1_mmcd.m
-
View all files
from
MATLAB in Physics - Visualisation
by Matt McDonnell
The first lecture in a series on using MATLABĀ® in undergraduate physics courses.
|
| makeSincMovie
|
function M = makeSincMovie
% Copyright 2008-2009 The MathWorks, Inc.
% Make suitable X and Y matricies to plot the sinc function over
[X, Y] = meshgrid(linspace(-3*pi, 3*pi, 50), linspace(-3*pi, 3*pi, 50));
% From X & Y make the matrix R of radius
R = sqrt(X.^2 + Y.^2);
% Calculate the sinc function from R
F = sin(R)./R;
% Make an amplitude vector that represents the various amplitudes we will
% movie the function over
A = linspace(-1, 1, 30);
% Iterate over each amplitude
for j = 1:numel(A)
% Plot the surface with colouring defined by the function with no
% amplitude modification
surf(X, Y, A(j)*F, F);
% Always use the same axis otherwise the movie will look funny
axis([-10 10 -10 10 -1 1]);
% Then turn off the axis - don't want tosee them in the movie. Also
% remove the lines around each face of the surface
axis off
shading flat
% Finally get this frame and the symmetric one so that when we show the
% whole movie it ends at the same point it began
M(j) = getframe; %#ok<AGROW>
M(2*numel(A) - j) = M(j); %#ok<AGROW>
end
|
|
Contact us at files@mathworks.com