SlideShare a Scribd company logo
1 of 19
Lab 5 template
%% Lab 5 - Your Name - MAT 275 Lab
% The Mass-Spring System
%% EX 1 10 pts
%A) 1 pts | short comment
%
%B) 2 pts | short comment
%
%C) 1 pts | short comment
%
%D) 1 pts
%E) 2 pts | List the first 3-4 t values either in decimal format or
as
%fractions involving pi
%F) 3 pts | comments. | (1 pts for including two distinct graphs,
each with y(t) and v(t) plotted)
%% EX 2 10 pts
%A) 5 pts
% add commands to LAB05ex1 to compute and plot E(t). Then
use ylim([~,~]) to change the yaxis limits.
% You don't need to include this code but at least one plot of
E(t) and a comment must be
% included!
%B) 2 pts | write out main steps here
% first differentiate E(t) with respect to t using the chain rule.
Then
% make substitutions using the expression for omega0 and using
the
% differential equation
%C) 3 pts | show plot and comment
%% EX 3 10 pts
%A) 3 pts | modify the system of equations in LAB05ex1a
% write the t value and either a) show correponding graph or b)
explain given matlab
% commands
%B) 2 pts | write t value and max |V| value; include figure
%note: velocity magnitude is like absolute value!
%C) 3 pts | include 3 figures here + comments.
% use title('text') to attach a title to the figure
%D) 2 pts | What needs to happen (in terms of the characteristic
equation)
%in order for there to be no oscillations? Impose a condition on
the
%characteristic equation to find the critical c value. Write out
main steps
%% EX4 10 pts
% A) 5 pts | include 1 figure and comment
%B) 2 pts
% again find dE/dt using the chain rule and make substitutions
based on the
% differential equation. You should reach an expression for
dE/dt which is
% in terms of y'
%C) 3 pts | include one figure and comment
Exercise (1):
function LAB05ex1
m = 1; % mass [kg]
k = 9; % spring constant [N/m]
omega0=sqrt(k/m);
y0=0.4; v0=0; % initial conditions
[t,Y]=ode45(@f,[0,10],[y0,v0],[],omega0); % solve for 0<t<10
y=Y(:,1); v=Y(:,2); % retrieve y, v from Y
figure(1); plot(t,y,'b+-',t,v,'ro-'); % time series for y and v
grid on;
%------------------------------------------------------
function dYdt= f(t,Y,omega0)
y = Y(1); v= Y(2);
dYdt = [v; -omega0^2*y];
Exercise (1a):
function LAB05ex1a
m = 1; % mass [kg]
k = 9; % spring constant [N/m]
c = 1; % friction coefficient [Ns/m]
omega0 = sqrt(k/m); p = c/(2*m);
y0 = 0.4; v0 = 0; % initial conditions
[t,Y]=ode45(@f,[0,10],[y0,v0],[],omega0,p); % solve for
0<t<10
y=Y(:,1); v=Y(:,2); % retrieve y, v from Y
figure(1); plot(t,y,'b+-',t,v,'ro-'); % time series for y and v
grid on
%------------------------------------------------------
function dYdt= f(t,Y,omega0,p)
y = Y(1); v= Y(2);
dYdt = [v; ?? ]; % fill-in dv/dt
More instructions for the lab write-up:
1) You are not obligated to use the 'diary' function. It was
presented only for you convenience. You
should be copying and pasting your code, plots, and results
into some sort of "Word" type editor that
will allow you to import graphs and such. Make sure you
always include the commands to generate
what is been asked and include the outputs (from command
window and plots), unless the problem
says to suppress it.
2) Edit this document: there should be no code or MATLAB
commands that do not pertain to the
exercises you are presenting in your final submission. For
each exercise, only the relevant code that
performs the task should be included. Do not include error
messages. So once you have determined
either the command line instructions or the appropriate script
file that will perform the task you are
given for the exercise, you should only include that and the
associated output. Copy/paste these into
your final submission document followed by the output
(including plots) that these MATLAB
instructions generate.
3) All code, output and plots for an exercise are to be grouped
together. Do not put them in appendix, at
the end of the writeup, etc. In particular, put any mfiles you
write BEFORE you first call them.
Each exercise, as well as the part of the exercises, is to be
clearly demarked. Do not blend them all
together into some sort of composition style paper,
complimentary to this: do NOT double space.
You can have spacing that makes your lab report look nice,
but do not double space sections of text
as you would in a literature paper.
4) You can suppress much of the MATLAB output. If you need
to create a vector, "x = 0:0.1:10" for
example, for use, there is no need to include this as output in
your writeup. Just make sure you
include whatever result you are asked to show. Plots also do
not have to be a full, or even half page.
They just have to be large enough that the relevant structure
can be seen.
5) Before you put down any code, plots, etc. answer whatever
questions that the exercise asks first.
You will follow this with the results of your work that
support your answer.
SAMPLE QUESTION:
Exercise 1: Consider the function
f (x,C)=
sin(C x)
Cx
(a) Create a vector x with 100 elements from -3*pi to 3*pi.
Write f as an inline or anonymous function
and generate the vectors y1 = f(x,C1), y2 = f(x,C2) and y3 =
f(x,C3), where C1 = 1, C2 = 2 and
C3 = 3. Make sure you suppress the output of x and y's
vectors. Plot the function f (for the three
C's above), name the axis, give a title to the plot and include
a legend to identify the plots. Add a
grid to the plot.
(b) Without using inline or anonymous functions write a
function+function structure m-file that does
the same job as in part (a)
SAMPLE LAB WRITEUP:
MAT 275 MATLAB LAB 1
NAME: __________________________
LAB DAY and TIME:______________
Instructor: _______________________
Exercise 1
(a)
x = linspace(-3*pi,3*pi); % generating x vector - default value
for number
% of pts linspace is 100
f= @(x,C) sin(C*x)./(C*x) % C will be just a constant, no need
for ".*"
C1 = 1, C2 = 2, C3 = 3 % Using commans to separate commands
y1 = f(x,C1); y2 = f(x,C2); y3 = f(x,C3); % supressing the y's
plot(x,y1,'b.-', x,y2,'ro-', x,y3,'ks-') % using different markers
for
% black and white plots
xlabel('x'), ylabel('y') % labeling the axis
title('f(x,C) = sin(Cx)/(Cx)') % adding a title
legend('C = 1','C = 2','C = 3') % adding a legend
grid on
Command window output:
f =
@(x,C)sin(C*x)./(C*x)
C1 =
1
C2 =
2
C3 =
3
(b)
M-file of structure function+function
function ex1
x = linspace(-3*pi,3*pi); % generating x vector - default value
for number
% of pts linspace is 100
C1 = 1, C2 = 2, C3 = 3 % Using commans to separate commands
y1 = f(x,C1); y2 = f(x,C2); y3 = f(x,C3); % function f is defined
below
plot(x,y1,'b.-', x,y2,'ro-', x,y3,'ks-') % using different markers
for
% black and white plots
xlabel('x'), ylabel('y') % labeling the axis
title('f(x,C) = sin(Cx)/(Cx)') % adding a title
legend('C = 1','C = 2','C = 3') % adding a legend
grid on
end
function y = f(x,C)
y = sin(C*x)./(C*x);
end
Command window output:
C1 =
1
C2 =
2
C3 =
3
MATLAB sessions: Laboratory 5
MAT 275 Laboratory 5
The Mass-Spring System
In this laboratory we will examine harmonic oscillation. We
will model the motion of a mass-spring
system with differential equations.
Our objectives are as follows:
1. Determine the effect of parameters on the solutions of
differential equations.
2. Determine the behavior of the mass-spring system from the
graph of the solution.
3. Determine the effect of the parameters on the behavior of the
mass-spring.
The primary MATLAB command used is the ode45 function.
Mass-Spring System without Damping
The motion of a mass suspended to a vertical spring can be
described as follows. When the spring is
not loaded it has length `0 (situation (a)). When a mass m is
attached to its lower end it has length `
(situation (b)). From the first principle of mechanics we then
obtain
mg︸︷︷︸
downward weight force
+ −k(` − `0)︸ ︷︷ ︸
upward tension force
= 0. (L5.1)
The term g measures the gravitational acceleration (g ' 9.8m/s2 '
32ft/s2). The quantity k is a spring
constant measuring its stiffness. We now pull downwards on the
mass by an amount y and let the mass
go (situation (c)). We expect the mass to oscillate around the
position y = 0. The second principle of
mechanics yields
mg︸︷︷︸
weight
+ −k(` + y − `0)︸ ︷︷ ︸
upward tension force
= m
d2(` + y)
dt2︸ ︷︷ ︸
acceleration of mass
, i.e., m
d2y
dt2
+ ky = 0 (L5.2)
using (L5.1). This ODE is second-order.
(a) (b) (c) (d)
y
`
`0
m
k
γ
Equation (L5.2) is rewritten
d2y
dt2
+ ω20y = 0 (L5.3)
c©2016 Stefania Tracogna, SoMSS, ASU 1
MATLAB sessions: Laboratory 5
where ω20 = k/m. Equation (L5.3) models simple harmonic
motion. A numerical solution with ini-
tial conditions y(0) = 0.4 meter and y′(0) = 0 (i.e., the mass is
initially stretched downward 40cms
and released, see setting (c) in figure) is obtained by first
reducing the ODE to first-order ODEs (see
Laboratory 4).
Let v = y′. Then v′ = y′′ = −ω20y = −9y. Also v(0) = y′(0) = 0.
The following MATLAB program
implements the problem (with ω0 = 3).
function LAB05ex1
m = 1; % mass [kg]
k = 9; % spring constant [N/m]
omega0 = sqrt(k/m);
y0 = 0.4; v0 = 0; % initial conditions
[t,Y] = ode45(@f,[0,10],[y0,v0],[],omega0); % solve for 0<t<10
y = Y(:,1); v = Y(:,2); % retrieve y, v from Y
figure(1); plot(t,y,’b+-’,t,v,’ro-’); % time series for y and v
grid on;
%-----------------------------------------
function dYdt = f(t,Y,omega0)
y = Y(1); v = Y(2);
dYdt = [ v ; -omega0^2*y ];
Note that the parameter ω0 was passed as an argument to ode45
rather than set to its value ω0 = 3
directly in the function f. The advantage is that its value can
easily be changed in the driver part of the
program rather than in the function, for example when multiple
plots with different values of ω0 need
to be compared in a single MATLAB figure window.
0 1 2 3 4 5 6 7 8 9 10
-1.5
-1
-0.5
0
0.5
1
1.5
Figure L5a: Harmonic motion
1. From the graph in Fig. L5a answer the following questions.
(a) Which curve represents y = y(t)? How do you know?
(b) What is the period of the motion? Answer this question first
graphically (by reading the
period from the graph) and then analytically (by finding the
period using ω0).
(c) We say that the mass comes to rest if, after a certain time,
the position of the mass remains
within an arbitrary small distance from the equilibrium position.
Will the mass ever come to
rest? Why?
c©2016 Stefania Tracogna, SoMSS, ASU 2
MATLAB sessions: Laboratory 5
(d) What is the amplitude of the oscillations for y?
(e) What is the maximum velocity (in magnitude) attained by
the mass, and when is it attained?
Make sure you give all the t-values at which the velocity is
maximum and the corresponding
maximum value. The t-values can be determined by magnifying
the MATLAB figure using
the magnify button , and by using the periodicity of the velocity
function.
(f) How does the size of the mass m and the stiffness k of the
spring affect the motion?
Support your answer first with a theoretical analysis on how ω0
– and therefore the period
of the oscillation – is related to m and k, and then graphically
by running LAB05ex1.m first
with m = 5 and k = 9 and then with m = 1 and k = 18. Include
the corresponding graphs.
2. The energy of the mass-spring system is given by the sum of
the potential energy and kinetic
energy. In absence of damping, the energy is conserved.
(a) Plot the quantity E = 1
2
mv2 + 1
2
ky2 as a function of time. What do you observe? (pay close
attention to the y-axis scale and, if necessary, use ylim to get a
better graph). Does the graph
confirm the fact that the energy is conserved?
(b) Show analytically that dE
dt
= 0.(Note that this proves that the energy is constant).
(c) Plot v vs y (phase plot). Does the curve ever get close to the
origin? Why or why not? What
does that mean for the mass-spring system?
Mass-Spring System with Damping
When the movement of the mass is damped due to viscous
effects (e.g., the mass moves in a cylinder
containing oil, situation (d)), an additional term proportional to
the velocity must be added. The
resulting equation becomes
m
d2y
dt2
+ c
dy
dt
+ ky = 0 or
d2y
dt2
+ 2p
dy
dt
+ ω20y = 0 (L5.4)
by setting p = c
2m
. The program LAB05ex1 is updated by modifying the function
f:
function LAB05ex1a
m = 1; % mass [kg]
k = 9; % spring constant [N/m]
c = 1; % friction coefficient [Ns/m]
omega0 = sqrt(k/m); p = c/(2*m);
y0 = 0.4; v0 = 0; % initial conditions
[t,Y] = ode45(@f,[0,10],[y0,v0],[],omega0,p); % solve for
0<t<10
y = Y(:,1); v = Y(:,2); % retrieve y, v from Y
figure(1); plot(t,y,’b+-’,t,v,’ro-’); % time series for y and v
grid on;
%-------------------------------------------
function dYdt = f(t,Y,omega0,p)
y = Y(1); v = Y(2);
dYdt = [ v ; ?? ]; % fill-in dv/dt
3. Fill in LAB05ex1a.m to reproduce Fig. L5b and then answer
the following questions.
(a) For what minimal time t1 will the mass-spring system
satisfy |y(t)| < 0.02 for all t > t1? You
can answer the question either by magnifying the MATLAB
figure using the magnify button
(include a graph that confirms your answer), or use the
following MATLAB commands
(explain):
c©2016 Stefania Tracogna, SoMSS, ASU 3
MATLAB sessions: Laboratory 5
0 1 2 3 4 5 6 7 8 9 10
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
y(t)
v(t)=y'(t)
Figure L5b: Damped harmonic motion
for i=1:length(y)
m(i)=max(abs(y(i:end)));
end
i = find(m<0.02); i = i(1);
disp([’|y|<0.02 for t>t1 with ’ num2str(t(i-1)) ’<t1<’
num2str(t(i))])
(b) What is the maximum (in magnitude) velocity attained by
the mass, and when is it attained?
Answer by using the magnify button and include the
corresponding picture.
(c) How does the size of c affect the motion? To support your
answer, run the file LAB05ex1.m
for c = 2, c = 6 and c = 10. Include the corresponding graphs
with a title indicating the
value of c used.
(d) Determine analytically the smallest (critical) value of c such
that no oscillation appears in
the solution.
4. (a) Plot the quantity E = 1
2
mv2 + 1
2
ky2 as a function of time. What do you observe? Is the
energy conserved in this case?
(b) Show analytically that dE
dt
< 0 for c > 0 while dE
dt
> 0 for c < 0.
(c) Plot v vs y (phase plot). Comment on the behavior of the
curve in the context of the motion
of the spring. Does the graph ever get close to the origin? Why
or why not?
c©2016 Stefania Tracogna, SoMSS, ASU 4

More Related Content

Similar to Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx

B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentationManchireddy Reddy
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabBilawalBaloch1
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.pptkebeAman
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabDnyanesh Patil
 
LAB05ex1.mfunction LAB05ex1m = 1; .docx
LAB05ex1.mfunction LAB05ex1m = 1;                          .docxLAB05ex1.mfunction LAB05ex1m = 1;                          .docx
LAB05ex1.mfunction LAB05ex1m = 1; .docxsmile790243
 
MATLAB sessions Laboratory 3MAT 275 Laboratory 3Numeric.docx
MATLAB sessions Laboratory 3MAT 275 Laboratory 3Numeric.docxMATLAB sessions Laboratory 3MAT 275 Laboratory 3Numeric.docx
MATLAB sessions Laboratory 3MAT 275 Laboratory 3Numeric.docxandreecapon
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMohd Esa
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2bilawalali74
 
MATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docx
MATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docxMATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docx
MATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docxandreecapon
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxDevaraj Chilakala
 
EE380-4 Course project Experimental determination of a Ser.docx
EE380-4  Course project Experimental determination of a  Ser.docxEE380-4  Course project Experimental determination of a  Ser.docx
EE380-4 Course project Experimental determination of a Ser.docxjack60216
 
A complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsA complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsMukesh Kumar
 
A MATLAB project on LCR circuits
A MATLAB project on LCR circuitsA MATLAB project on LCR circuits
A MATLAB project on LCR circuitssvrohith 9
 
1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptx1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptxBeheraA
 
COMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptxCOMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptximman gwu
 

Similar to Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx (20)

B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.ppt
 
Tutorial2
Tutorial2Tutorial2
Tutorial2
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
LAB05ex1.mfunction LAB05ex1m = 1; .docx
LAB05ex1.mfunction LAB05ex1m = 1;                          .docxLAB05ex1.mfunction LAB05ex1m = 1;                          .docx
LAB05ex1.mfunction LAB05ex1m = 1; .docx
 
Matlab1
Matlab1Matlab1
Matlab1
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
 
MATLAB sessions Laboratory 3MAT 275 Laboratory 3Numeric.docx
MATLAB sessions Laboratory 3MAT 275 Laboratory 3Numeric.docxMATLAB sessions Laboratory 3MAT 275 Laboratory 3Numeric.docx
MATLAB sessions Laboratory 3MAT 275 Laboratory 3Numeric.docx
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd Esa
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2
 
MATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docx
MATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docxMATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docx
MATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docx
 
Matlabtut1
Matlabtut1Matlabtut1
Matlabtut1
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptx
 
EE380-4 Course project Experimental determination of a Ser.docx
EE380-4  Course project Experimental determination of a  Ser.docxEE380-4  Course project Experimental determination of a  Ser.docx
EE380-4 Course project Experimental determination of a Ser.docx
 
A complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsA complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projects
 
A MATLAB project on LCR circuits
A MATLAB project on LCR circuitsA MATLAB project on LCR circuits
A MATLAB project on LCR circuits
 
Programming with matlab session 1
Programming with matlab session 1Programming with matlab session 1
Programming with matlab session 1
 
1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptx1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptx
 
COMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptxCOMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptx
 

More from smile790243

PART B Please response to these two original posts below. Wh.docx
PART B Please response to these two original posts below. Wh.docxPART B Please response to these two original posts below. Wh.docx
PART B Please response to these two original posts below. Wh.docxsmile790243
 
Part C Developing Your Design SolutionThe Production Cycle.docx
Part C Developing Your Design SolutionThe Production Cycle.docxPart C Developing Your Design SolutionThe Production Cycle.docx
Part C Developing Your Design SolutionThe Production Cycle.docxsmile790243
 
PART A You will create a media piece based around the theme of a.docx
PART A You will create a media piece based around the theme of a.docxPART A You will create a media piece based around the theme of a.docx
PART A You will create a media piece based around the theme of a.docxsmile790243
 
Part 4. Implications to Nursing Practice & Implication to Patien.docx
Part 4. Implications to Nursing Practice & Implication to Patien.docxPart 4. Implications to Nursing Practice & Implication to Patien.docx
Part 4. Implications to Nursing Practice & Implication to Patien.docxsmile790243
 
PART AHepatitis C is a chronic liver infection that can be e.docx
PART AHepatitis C is a chronic liver infection that can be e.docxPART AHepatitis C is a chronic liver infection that can be e.docx
PART AHepatitis C is a chronic liver infection that can be e.docxsmile790243
 
Part A post your answer to the following question1. How m.docx
Part A post your answer to the following question1. How m.docxPart A post your answer to the following question1. How m.docx
Part A post your answer to the following question1. How m.docxsmile790243
 
PART BPlease response to these two original posts below..docx
PART BPlease response to these two original posts below..docxPART BPlease response to these two original posts below..docx
PART BPlease response to these two original posts below..docxsmile790243
 
Part A (50 Points)Various men and women throughout history .docx
Part A (50 Points)Various men and women throughout history .docxPart A (50 Points)Various men and women throughout history .docx
Part A (50 Points)Various men and women throughout history .docxsmile790243
 
Part A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docx
Part A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docxPart A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docx
Part A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docxsmile790243
 
Part A Develop an original age-appropriate activity for your .docx
Part A Develop an original age-appropriate activity for your .docxPart A Develop an original age-appropriate activity for your .docx
Part A Develop an original age-appropriate activity for your .docxsmile790243
 
Part 3 Social Situations2. Identify multicultural challenges th.docx
Part 3 Social Situations2. Identify multicultural challenges th.docxPart 3 Social Situations2. Identify multicultural challenges th.docx
Part 3 Social Situations2. Identify multicultural challenges th.docxsmile790243
 
Part A (1000 words) Annotated Bibliography - Create an annota.docx
Part A (1000 words) Annotated Bibliography - Create an annota.docxPart A (1000 words) Annotated Bibliography - Create an annota.docx
Part A (1000 words) Annotated Bibliography - Create an annota.docxsmile790243
 
Part 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docx
Part 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docxPart 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docx
Part 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docxsmile790243
 
Part 3 Social Situations • Proposal paper which identifies multicul.docx
Part 3 Social Situations • Proposal paper which identifies multicul.docxPart 3 Social Situations • Proposal paper which identifies multicul.docx
Part 3 Social Situations • Proposal paper which identifies multicul.docxsmile790243
 
Part 3 Social Situations 2. Identify multicultural challenges that .docx
Part 3 Social Situations 2. Identify multicultural challenges that .docxPart 3 Social Situations 2. Identify multicultural challenges that .docx
Part 3 Social Situations 2. Identify multicultural challenges that .docxsmile790243
 
Part 2The client is a 32-year-old Hispanic American male who c.docx
Part 2The client is a 32-year-old Hispanic American male who c.docxPart 2The client is a 32-year-old Hispanic American male who c.docx
Part 2The client is a 32-year-old Hispanic American male who c.docxsmile790243
 
Part 2For this section of the template, focus on gathering deta.docx
Part 2For this section of the template, focus on gathering deta.docxPart 2For this section of the template, focus on gathering deta.docx
Part 2For this section of the template, focus on gathering deta.docxsmile790243
 
Part 2 Observation Summary and Analysis • Summary paper of observat.docx
Part 2 Observation Summary and Analysis • Summary paper of observat.docxPart 2 Observation Summary and Analysis • Summary paper of observat.docx
Part 2 Observation Summary and Analysis • Summary paper of observat.docxsmile790243
 
Part 2 Observation Summary and Analysis 1. Review and implement any.docx
Part 2 Observation Summary and Analysis 1. Review and implement any.docxPart 2 Observation Summary and Analysis 1. Review and implement any.docx
Part 2 Observation Summary and Analysis 1. Review and implement any.docxsmile790243
 
Part 2Data collectionfrom your change study initiative,.docx
Part 2Data collectionfrom your change study initiative,.docxPart 2Data collectionfrom your change study initiative,.docx
Part 2Data collectionfrom your change study initiative,.docxsmile790243
 

More from smile790243 (20)

PART B Please response to these two original posts below. Wh.docx
PART B Please response to these two original posts below. Wh.docxPART B Please response to these two original posts below. Wh.docx
PART B Please response to these two original posts below. Wh.docx
 
Part C Developing Your Design SolutionThe Production Cycle.docx
Part C Developing Your Design SolutionThe Production Cycle.docxPart C Developing Your Design SolutionThe Production Cycle.docx
Part C Developing Your Design SolutionThe Production Cycle.docx
 
PART A You will create a media piece based around the theme of a.docx
PART A You will create a media piece based around the theme of a.docxPART A You will create a media piece based around the theme of a.docx
PART A You will create a media piece based around the theme of a.docx
 
Part 4. Implications to Nursing Practice & Implication to Patien.docx
Part 4. Implications to Nursing Practice & Implication to Patien.docxPart 4. Implications to Nursing Practice & Implication to Patien.docx
Part 4. Implications to Nursing Practice & Implication to Patien.docx
 
PART AHepatitis C is a chronic liver infection that can be e.docx
PART AHepatitis C is a chronic liver infection that can be e.docxPART AHepatitis C is a chronic liver infection that can be e.docx
PART AHepatitis C is a chronic liver infection that can be e.docx
 
Part A post your answer to the following question1. How m.docx
Part A post your answer to the following question1. How m.docxPart A post your answer to the following question1. How m.docx
Part A post your answer to the following question1. How m.docx
 
PART BPlease response to these two original posts below..docx
PART BPlease response to these two original posts below..docxPART BPlease response to these two original posts below..docx
PART BPlease response to these two original posts below..docx
 
Part A (50 Points)Various men and women throughout history .docx
Part A (50 Points)Various men and women throughout history .docxPart A (50 Points)Various men and women throughout history .docx
Part A (50 Points)Various men and women throughout history .docx
 
Part A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docx
Part A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docxPart A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docx
Part A1. K2. D3. N4. C5. A6. O7. F8. Q9. H10..docx
 
Part A Develop an original age-appropriate activity for your .docx
Part A Develop an original age-appropriate activity for your .docxPart A Develop an original age-appropriate activity for your .docx
Part A Develop an original age-appropriate activity for your .docx
 
Part 3 Social Situations2. Identify multicultural challenges th.docx
Part 3 Social Situations2. Identify multicultural challenges th.docxPart 3 Social Situations2. Identify multicultural challenges th.docx
Part 3 Social Situations2. Identify multicultural challenges th.docx
 
Part A (1000 words) Annotated Bibliography - Create an annota.docx
Part A (1000 words) Annotated Bibliography - Create an annota.docxPart A (1000 words) Annotated Bibliography - Create an annota.docx
Part A (1000 words) Annotated Bibliography - Create an annota.docx
 
Part 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docx
Part 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docxPart 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docx
Part 6 Disseminating Results Create a 5-minute, 5- to 6-sli.docx
 
Part 3 Social Situations • Proposal paper which identifies multicul.docx
Part 3 Social Situations • Proposal paper which identifies multicul.docxPart 3 Social Situations • Proposal paper which identifies multicul.docx
Part 3 Social Situations • Proposal paper which identifies multicul.docx
 
Part 3 Social Situations 2. Identify multicultural challenges that .docx
Part 3 Social Situations 2. Identify multicultural challenges that .docxPart 3 Social Situations 2. Identify multicultural challenges that .docx
Part 3 Social Situations 2. Identify multicultural challenges that .docx
 
Part 2The client is a 32-year-old Hispanic American male who c.docx
Part 2The client is a 32-year-old Hispanic American male who c.docxPart 2The client is a 32-year-old Hispanic American male who c.docx
Part 2The client is a 32-year-old Hispanic American male who c.docx
 
Part 2For this section of the template, focus on gathering deta.docx
Part 2For this section of the template, focus on gathering deta.docxPart 2For this section of the template, focus on gathering deta.docx
Part 2For this section of the template, focus on gathering deta.docx
 
Part 2 Observation Summary and Analysis • Summary paper of observat.docx
Part 2 Observation Summary and Analysis • Summary paper of observat.docxPart 2 Observation Summary and Analysis • Summary paper of observat.docx
Part 2 Observation Summary and Analysis • Summary paper of observat.docx
 
Part 2 Observation Summary and Analysis 1. Review and implement any.docx
Part 2 Observation Summary and Analysis 1. Review and implement any.docxPart 2 Observation Summary and Analysis 1. Review and implement any.docx
Part 2 Observation Summary and Analysis 1. Review and implement any.docx
 
Part 2Data collectionfrom your change study initiative,.docx
Part 2Data collectionfrom your change study initiative,.docxPart 2Data collectionfrom your change study initiative,.docx
Part 2Data collectionfrom your change study initiative,.docx
 

Recently uploaded

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 

Recently uploaded (20)

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 

Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx

  • 1. Lab 5 template %% Lab 5 - Your Name - MAT 275 Lab % The Mass-Spring System %% EX 1 10 pts %A) 1 pts | short comment % %B) 2 pts | short comment % %C) 1 pts | short comment % %D) 1 pts %E) 2 pts | List the first 3-4 t values either in decimal format or as %fractions involving pi %F) 3 pts | comments. | (1 pts for including two distinct graphs, each with y(t) and v(t) plotted) %% EX 2 10 pts %A) 5 pts % add commands to LAB05ex1 to compute and plot E(t). Then use ylim([~,~]) to change the yaxis limits. % You don't need to include this code but at least one plot of E(t) and a comment must be % included! %B) 2 pts | write out main steps here % first differentiate E(t) with respect to t using the chain rule. Then % make substitutions using the expression for omega0 and using the
  • 2. % differential equation %C) 3 pts | show plot and comment %% EX 3 10 pts %A) 3 pts | modify the system of equations in LAB05ex1a % write the t value and either a) show correponding graph or b) explain given matlab % commands %B) 2 pts | write t value and max |V| value; include figure %note: velocity magnitude is like absolute value! %C) 3 pts | include 3 figures here + comments. % use title('text') to attach a title to the figure %D) 2 pts | What needs to happen (in terms of the characteristic equation) %in order for there to be no oscillations? Impose a condition on the %characteristic equation to find the critical c value. Write out main steps %% EX4 10 pts % A) 5 pts | include 1 figure and comment %B) 2 pts % again find dE/dt using the chain rule and make substitutions based on the % differential equation. You should reach an expression for dE/dt which is % in terms of y' %C) 3 pts | include one figure and comment Exercise (1): function LAB05ex1
  • 3. m = 1; % mass [kg] k = 9; % spring constant [N/m] omega0=sqrt(k/m); y0=0.4; v0=0; % initial conditions [t,Y]=ode45(@f,[0,10],[y0,v0],[],omega0); % solve for 0<t<10 y=Y(:,1); v=Y(:,2); % retrieve y, v from Y figure(1); plot(t,y,'b+-',t,v,'ro-'); % time series for y and v grid on; %------------------------------------------------------ function dYdt= f(t,Y,omega0) y = Y(1); v= Y(2); dYdt = [v; -omega0^2*y]; Exercise (1a): function LAB05ex1a m = 1; % mass [kg] k = 9; % spring constant [N/m] c = 1; % friction coefficient [Ns/m] omega0 = sqrt(k/m); p = c/(2*m); y0 = 0.4; v0 = 0; % initial conditions [t,Y]=ode45(@f,[0,10],[y0,v0],[],omega0,p); % solve for 0<t<10 y=Y(:,1); v=Y(:,2); % retrieve y, v from Y figure(1); plot(t,y,'b+-',t,v,'ro-'); % time series for y and v grid on %------------------------------------------------------ function dYdt= f(t,Y,omega0,p)
  • 4. y = Y(1); v= Y(2); dYdt = [v; ?? ]; % fill-in dv/dt More instructions for the lab write-up: 1) You are not obligated to use the 'diary' function. It was presented only for you convenience. You should be copying and pasting your code, plots, and results into some sort of "Word" type editor that will allow you to import graphs and such. Make sure you always include the commands to generate what is been asked and include the outputs (from command window and plots), unless the problem says to suppress it. 2) Edit this document: there should be no code or MATLAB commands that do not pertain to the exercises you are presenting in your final submission. For each exercise, only the relevant code that performs the task should be included. Do not include error messages. So once you have determined either the command line instructions or the appropriate script file that will perform the task you are given for the exercise, you should only include that and the associated output. Copy/paste these into your final submission document followed by the output (including plots) that these MATLAB instructions generate. 3) All code, output and plots for an exercise are to be grouped together. Do not put them in appendix, at the end of the writeup, etc. In particular, put any mfiles you write BEFORE you first call them. Each exercise, as well as the part of the exercises, is to be
  • 5. clearly demarked. Do not blend them all together into some sort of composition style paper, complimentary to this: do NOT double space. You can have spacing that makes your lab report look nice, but do not double space sections of text as you would in a literature paper. 4) You can suppress much of the MATLAB output. If you need to create a vector, "x = 0:0.1:10" for example, for use, there is no need to include this as output in your writeup. Just make sure you include whatever result you are asked to show. Plots also do not have to be a full, or even half page. They just have to be large enough that the relevant structure can be seen. 5) Before you put down any code, plots, etc. answer whatever questions that the exercise asks first. You will follow this with the results of your work that support your answer. SAMPLE QUESTION: Exercise 1: Consider the function f (x,C)= sin(C x) Cx (a) Create a vector x with 100 elements from -3*pi to 3*pi. Write f as an inline or anonymous function and generate the vectors y1 = f(x,C1), y2 = f(x,C2) and y3 = f(x,C3), where C1 = 1, C2 = 2 and
  • 6. C3 = 3. Make sure you suppress the output of x and y's vectors. Plot the function f (for the three C's above), name the axis, give a title to the plot and include a legend to identify the plots. Add a grid to the plot. (b) Without using inline or anonymous functions write a function+function structure m-file that does the same job as in part (a) SAMPLE LAB WRITEUP: MAT 275 MATLAB LAB 1 NAME: __________________________ LAB DAY and TIME:______________ Instructor: _______________________ Exercise 1 (a) x = linspace(-3*pi,3*pi); % generating x vector - default value for number % of pts linspace is 100 f= @(x,C) sin(C*x)./(C*x) % C will be just a constant, no need for ".*" C1 = 1, C2 = 2, C3 = 3 % Using commans to separate commands y1 = f(x,C1); y2 = f(x,C2); y3 = f(x,C3); % supressing the y's plot(x,y1,'b.-', x,y2,'ro-', x,y3,'ks-') % using different markers for % black and white plots xlabel('x'), ylabel('y') % labeling the axis
  • 7. title('f(x,C) = sin(Cx)/(Cx)') % adding a title legend('C = 1','C = 2','C = 3') % adding a legend grid on Command window output: f = @(x,C)sin(C*x)./(C*x) C1 = 1 C2 = 2 C3 = 3 (b) M-file of structure function+function function ex1 x = linspace(-3*pi,3*pi); % generating x vector - default value for number % of pts linspace is 100 C1 = 1, C2 = 2, C3 = 3 % Using commans to separate commands y1 = f(x,C1); y2 = f(x,C2); y3 = f(x,C3); % function f is defined below plot(x,y1,'b.-', x,y2,'ro-', x,y3,'ks-') % using different markers
  • 8. for % black and white plots xlabel('x'), ylabel('y') % labeling the axis title('f(x,C) = sin(Cx)/(Cx)') % adding a title legend('C = 1','C = 2','C = 3') % adding a legend grid on end function y = f(x,C) y = sin(C*x)./(C*x); end Command window output: C1 = 1 C2 = 2 C3 = 3 MATLAB sessions: Laboratory 5 MAT 275 Laboratory 5 The Mass-Spring System In this laboratory we will examine harmonic oscillation. We will model the motion of a mass-spring
  • 9. system with differential equations. Our objectives are as follows: 1. Determine the effect of parameters on the solutions of differential equations. 2. Determine the behavior of the mass-spring system from the graph of the solution. 3. Determine the effect of the parameters on the behavior of the mass-spring. The primary MATLAB command used is the ode45 function. Mass-Spring System without Damping The motion of a mass suspended to a vertical spring can be described as follows. When the spring is not loaded it has length `0 (situation (a)). When a mass m is attached to its lower end it has length ` (situation (b)). From the first principle of mechanics we then obtain mg︸︷︷︸ downward weight force + −k(` − `0)︸ ︷︷ ︸ upward tension force = 0. (L5.1) The term g measures the gravitational acceleration (g ' 9.8m/s2 ' 32ft/s2). The quantity k is a spring constant measuring its stiffness. We now pull downwards on the mass by an amount y and let the mass
  • 10. go (situation (c)). We expect the mass to oscillate around the position y = 0. The second principle of mechanics yields mg︸︷︷︸ weight + −k(` + y − `0)︸ ︷︷ ︸ upward tension force = m d2(` + y) dt2︸ ︷︷ ︸ acceleration of mass , i.e., m d2y dt2 + ky = 0 (L5.2) using (L5.1). This ODE is second-order. (a) (b) (c) (d) y ` `0 m k
  • 11. γ Equation (L5.2) is rewritten d2y dt2 + ω20y = 0 (L5.3) c©2016 Stefania Tracogna, SoMSS, ASU 1 MATLAB sessions: Laboratory 5 where ω20 = k/m. Equation (L5.3) models simple harmonic motion. A numerical solution with ini- tial conditions y(0) = 0.4 meter and y′(0) = 0 (i.e., the mass is initially stretched downward 40cms and released, see setting (c) in figure) is obtained by first reducing the ODE to first-order ODEs (see Laboratory 4). Let v = y′. Then v′ = y′′ = −ω20y = −9y. Also v(0) = y′(0) = 0. The following MATLAB program implements the problem (with ω0 = 3). function LAB05ex1 m = 1; % mass [kg] k = 9; % spring constant [N/m] omega0 = sqrt(k/m); y0 = 0.4; v0 = 0; % initial conditions
  • 12. [t,Y] = ode45(@f,[0,10],[y0,v0],[],omega0); % solve for 0<t<10 y = Y(:,1); v = Y(:,2); % retrieve y, v from Y figure(1); plot(t,y,’b+-’,t,v,’ro-’); % time series for y and v grid on; %----------------------------------------- function dYdt = f(t,Y,omega0) y = Y(1); v = Y(2); dYdt = [ v ; -omega0^2*y ]; Note that the parameter ω0 was passed as an argument to ode45 rather than set to its value ω0 = 3 directly in the function f. The advantage is that its value can easily be changed in the driver part of the program rather than in the function, for example when multiple plots with different values of ω0 need to be compared in a single MATLAB figure window. 0 1 2 3 4 5 6 7 8 9 10 -1.5 -1 -0.5 0 0.5
  • 13. 1 1.5 Figure L5a: Harmonic motion 1. From the graph in Fig. L5a answer the following questions. (a) Which curve represents y = y(t)? How do you know? (b) What is the period of the motion? Answer this question first graphically (by reading the period from the graph) and then analytically (by finding the period using ω0). (c) We say that the mass comes to rest if, after a certain time, the position of the mass remains within an arbitrary small distance from the equilibrium position. Will the mass ever come to rest? Why? c©2016 Stefania Tracogna, SoMSS, ASU 2 MATLAB sessions: Laboratory 5 (d) What is the amplitude of the oscillations for y? (e) What is the maximum velocity (in magnitude) attained by the mass, and when is it attained? Make sure you give all the t-values at which the velocity is maximum and the corresponding maximum value. The t-values can be determined by magnifying the MATLAB figure using
  • 14. the magnify button , and by using the periodicity of the velocity function. (f) How does the size of the mass m and the stiffness k of the spring affect the motion? Support your answer first with a theoretical analysis on how ω0 – and therefore the period of the oscillation – is related to m and k, and then graphically by running LAB05ex1.m first with m = 5 and k = 9 and then with m = 1 and k = 18. Include the corresponding graphs. 2. The energy of the mass-spring system is given by the sum of the potential energy and kinetic energy. In absence of damping, the energy is conserved. (a) Plot the quantity E = 1 2 mv2 + 1 2 ky2 as a function of time. What do you observe? (pay close attention to the y-axis scale and, if necessary, use ylim to get a better graph). Does the graph confirm the fact that the energy is conserved? (b) Show analytically that dE dt = 0.(Note that this proves that the energy is constant). (c) Plot v vs y (phase plot). Does the curve ever get close to the origin? Why or why not? What does that mean for the mass-spring system?
  • 15. Mass-Spring System with Damping When the movement of the mass is damped due to viscous effects (e.g., the mass moves in a cylinder containing oil, situation (d)), an additional term proportional to the velocity must be added. The resulting equation becomes m d2y dt2 + c dy dt + ky = 0 or d2y dt2 + 2p dy dt + ω20y = 0 (L5.4) by setting p = c 2m . The program LAB05ex1 is updated by modifying the function f: function LAB05ex1a
  • 16. m = 1; % mass [kg] k = 9; % spring constant [N/m] c = 1; % friction coefficient [Ns/m] omega0 = sqrt(k/m); p = c/(2*m); y0 = 0.4; v0 = 0; % initial conditions [t,Y] = ode45(@f,[0,10],[y0,v0],[],omega0,p); % solve for 0<t<10 y = Y(:,1); v = Y(:,2); % retrieve y, v from Y figure(1); plot(t,y,’b+-’,t,v,’ro-’); % time series for y and v grid on; %------------------------------------------- function dYdt = f(t,Y,omega0,p) y = Y(1); v = Y(2); dYdt = [ v ; ?? ]; % fill-in dv/dt 3. Fill in LAB05ex1a.m to reproduce Fig. L5b and then answer the following questions. (a) For what minimal time t1 will the mass-spring system satisfy |y(t)| < 0.02 for all t > t1? You can answer the question either by magnifying the MATLAB figure using the magnify button
  • 17. (include a graph that confirms your answer), or use the following MATLAB commands (explain): c©2016 Stefania Tracogna, SoMSS, ASU 3 MATLAB sessions: Laboratory 5 0 1 2 3 4 5 6 7 8 9 10 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 y(t) v(t)=y'(t) Figure L5b: Damped harmonic motion for i=1:length(y)
  • 18. m(i)=max(abs(y(i:end))); end i = find(m<0.02); i = i(1); disp([’|y|<0.02 for t>t1 with ’ num2str(t(i-1)) ’<t1<’ num2str(t(i))]) (b) What is the maximum (in magnitude) velocity attained by the mass, and when is it attained? Answer by using the magnify button and include the corresponding picture. (c) How does the size of c affect the motion? To support your answer, run the file LAB05ex1.m for c = 2, c = 6 and c = 10. Include the corresponding graphs with a title indicating the value of c used. (d) Determine analytically the smallest (critical) value of c such that no oscillation appears in the solution. 4. (a) Plot the quantity E = 1 2 mv2 + 1 2 ky2 as a function of time. What do you observe? Is the energy conserved in this case? (b) Show analytically that dE dt
  • 19. < 0 for c > 0 while dE dt > 0 for c < 0. (c) Plot v vs y (phase plot). Comment on the behavior of the curve in the context of the motion of the spring. Does the graph ever get close to the origin? Why or why not? c©2016 Stefania Tracogna, SoMSS, ASU 4