SlideShare a Scribd company logo
1 of 19
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
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.
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
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 Related Content

Similar to SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx

Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMohd Esa
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxDevaraj Chilakala
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2bilawalali74
 
Solution of matlab chapter 3
Solution of matlab chapter 3Solution of matlab chapter 3
Solution of matlab chapter 3AhsanIrshad8
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxandreecapon
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabBilawalBaloch1
 
Matlab practice
Matlab practiceMatlab practice
Matlab practiceZunAib Ali
 
Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab
 
Matlab ch1 intro
Matlab ch1 introMatlab ch1 intro
Matlab ch1 introRagu Nathan
 
Analysing simple pendulum using matlab
Analysing simple pendulum using matlabAnalysing simple pendulum using matlab
Analysing simple pendulum using matlabAkshay Mistri
 

Similar to SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx (20)

Matlab booklet
Matlab bookletMatlab booklet
Matlab booklet
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd Esa
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptx
 
MATLABgraphPlotting.pptx
MATLABgraphPlotting.pptxMATLABgraphPlotting.pptx
MATLABgraphPlotting.pptx
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2
 
Solution of matlab chapter 3
Solution of matlab chapter 3Solution of matlab chapter 3
Solution of matlab chapter 3
 
Online Maths Assignment Help
Online Maths Assignment HelpOnline Maths Assignment Help
Online Maths Assignment Help
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
 
Tutorial 2
Tutorial     2Tutorial     2
Tutorial 2
 
Online Maths Assignment Help
Online Maths Assignment HelpOnline Maths Assignment Help
Online Maths Assignment Help
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Matlab practice
Matlab practiceMatlab practice
Matlab practice
 
Signals and Systems Homework Help.pptx
Signals and Systems Homework Help.pptxSignals and Systems Homework Help.pptx
Signals and Systems Homework Help.pptx
 
Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2
 
Matlab1
Matlab1Matlab1
Matlab1
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
 
Matlab ch1 intro
Matlab ch1 introMatlab ch1 intro
Matlab ch1 intro
 
Computer Network Homework Help
Computer Network Homework HelpComputer Network Homework Help
Computer Network Homework Help
 
Matlabtut1
Matlabtut1Matlabtut1
Matlabtut1
 
Analysing simple pendulum using matlab
Analysing simple pendulum using matlabAnalysing simple pendulum using matlab
Analysing simple pendulum using matlab
 

More from anhlodge

…if one of the primary purposes of education is to teach young .docx
…if one of the primary purposes of education is to teach young .docx…if one of the primary purposes of education is to teach young .docx
…if one of the primary purposes of education is to teach young .docxanhlodge
 
✍Report OverviewIn this assignment, you will Document an.docx
✍Report OverviewIn this assignment, you will Document an.docx✍Report OverviewIn this assignment, you will Document an.docx
✍Report OverviewIn this assignment, you will Document an.docxanhlodge
 
☰Menu×NURS 6050 Policy and Advocacy for Improving Population H.docx
☰Menu×NURS 6050 Policy and Advocacy for Improving Population H.docx☰Menu×NURS 6050 Policy and Advocacy for Improving Population H.docx
☰Menu×NURS 6050 Policy and Advocacy for Improving Population H.docxanhlodge
 
▪ Learning Outcomes1.Understand the basic concepts and termin.docx
▪ Learning Outcomes1.Understand the basic concepts and termin.docx▪ Learning Outcomes1.Understand the basic concepts and termin.docx
▪ Learning Outcomes1.Understand the basic concepts and termin.docxanhlodge
 
●  What are some of the reasons that a MNE would choose internationa.docx
●  What are some of the reasons that a MNE would choose internationa.docx●  What are some of the reasons that a MNE would choose internationa.docx
●  What are some of the reasons that a MNE would choose internationa.docxanhlodge
 
■ Research PaperGeneral Systems Theory Its Past andPote.docx
■ Research PaperGeneral Systems Theory Its Past andPote.docx■ Research PaperGeneral Systems Theory Its Past andPote.docx
■ Research PaperGeneral Systems Theory Its Past andPote.docxanhlodge
 
▶︎ Prompt 1 Think about whether you identify with either Blue or .docx
▶︎ Prompt 1 Think about whether you identify with either Blue or .docx▶︎ Prompt 1 Think about whether you identify with either Blue or .docx
▶︎ Prompt 1 Think about whether you identify with either Blue or .docxanhlodge
 
⁞ InstructionsChoose only ONE  of the following options .docx
⁞ InstructionsChoose only ONE  of the following options .docx⁞ InstructionsChoose only ONE  of the following options .docx
⁞ InstructionsChoose only ONE  of the following options .docxanhlodge
 
⁞ InstructionsChoose only ONE of the following options below.docx
⁞ InstructionsChoose only ONE of the following options below.docx⁞ InstructionsChoose only ONE of the following options below.docx
⁞ InstructionsChoose only ONE of the following options below.docxanhlodge
 
⁞ InstructionsAfter reading  The Metamorphosis by Frank .docx
⁞ InstructionsAfter reading  The Metamorphosis by Frank .docx⁞ InstructionsAfter reading  The Metamorphosis by Frank .docx
⁞ InstructionsAfter reading  The Metamorphosis by Frank .docxanhlodge
 
⁞ InstructionsAfter reading all of Chapter 5, please se.docx
⁞ InstructionsAfter reading all of Chapter 5, please se.docx⁞ InstructionsAfter reading all of Chapter 5, please se.docx
⁞ InstructionsAfter reading all of Chapter 5, please se.docxanhlodge
 
⁞ InstructionsAfter reading all of Chapter 2, please select.docx
⁞ InstructionsAfter reading all of Chapter 2, please select.docx⁞ InstructionsAfter reading all of Chapter 2, please select.docx
⁞ InstructionsAfter reading all of Chapter 2, please select.docxanhlodge
 
⁞ Instructions After reading all of Chapter 9, please .docx
⁞ Instructions After reading all of Chapter 9, please .docx⁞ Instructions After reading all of Chapter 9, please .docx
⁞ Instructions After reading all of Chapter 9, please .docxanhlodge
 
…Multiple intelligences describe an individual’s strengths or capac.docx
…Multiple intelligences describe an individual’s strengths or capac.docx…Multiple intelligences describe an individual’s strengths or capac.docx
…Multiple intelligences describe an individual’s strengths or capac.docxanhlodge
 
••• JONATHAN LETHEM CRITICS OFTEN USE the word prolifi.docx
••• JONATHAN LETHEM CRITICS OFTEN USE the word prolifi.docx••• JONATHAN LETHEM CRITICS OFTEN USE the word prolifi.docx
••• JONATHAN LETHEM CRITICS OFTEN USE the word prolifi.docxanhlodge
 
•••••iA National Profile ofthe Real Estate Industry and.docx
•••••iA National Profile ofthe Real Estate Industry and.docx•••••iA National Profile ofthe Real Estate Industry and.docx
•••••iA National Profile ofthe Real Estate Industry and.docxanhlodge
 

Let us consider […] a pair of cases which I shall call Rescue .docx

Let us consider […] a pair of cases which I shall call Rescue .docx
Let us consider […] a pair of cases which I shall call Rescue .docx

Let us consider […] a pair of cases which I shall call Rescue .docxanhlodge
 
•  Enhanced eText—Keeps students engaged in learning on th.docx
•  Enhanced eText—Keeps students engaged in learning on th.docx•  Enhanced eText—Keeps students engaged in learning on th.docx
•  Enhanced eText—Keeps students engaged in learning on th.docxanhlodge
 
•    Here’s the approach you can take for this paperTitle.docx
•    Here’s the approach you can take for this paperTitle.docx•    Here’s the approach you can take for this paperTitle.docx
•    Here’s the approach you can take for this paperTitle.docxanhlodge
 
•Your team will select a big data analytics project that is intr.docx
•Your team will select a big data analytics project that is intr.docx•Your team will select a big data analytics project that is intr.docx
•Your team will select a big data analytics project that is intr.docxanhlodge
 

More from anhlodge (20)

…if one of the primary purposes of education is to teach young .docx
…if one of the primary purposes of education is to teach young .docx…if one of the primary purposes of education is to teach young .docx
…if one of the primary purposes of education is to teach young .docx
 
✍Report OverviewIn this assignment, you will Document an.docx
✍Report OverviewIn this assignment, you will Document an.docx✍Report OverviewIn this assignment, you will Document an.docx
✍Report OverviewIn this assignment, you will Document an.docx
 
☰Menu×NURS 6050 Policy and Advocacy for Improving Population H.docx
☰Menu×NURS 6050 Policy and Advocacy for Improving Population H.docx☰Menu×NURS 6050 Policy and Advocacy for Improving Population H.docx
☰Menu×NURS 6050 Policy and Advocacy for Improving Population H.docx
 
▪ Learning Outcomes1.Understand the basic concepts and termin.docx
▪ Learning Outcomes1.Understand the basic concepts and termin.docx▪ Learning Outcomes1.Understand the basic concepts and termin.docx
▪ Learning Outcomes1.Understand the basic concepts and termin.docx
 
●  What are some of the reasons that a MNE would choose internationa.docx
●  What are some of the reasons that a MNE would choose internationa.docx●  What are some of the reasons that a MNE would choose internationa.docx
●  What are some of the reasons that a MNE would choose internationa.docx
 
■ Research PaperGeneral Systems Theory Its Past andPote.docx
■ Research PaperGeneral Systems Theory Its Past andPote.docx■ Research PaperGeneral Systems Theory Its Past andPote.docx
■ Research PaperGeneral Systems Theory Its Past andPote.docx
 
▶︎ Prompt 1 Think about whether you identify with either Blue or .docx
▶︎ Prompt 1 Think about whether you identify with either Blue or .docx▶︎ Prompt 1 Think about whether you identify with either Blue or .docx
▶︎ Prompt 1 Think about whether you identify with either Blue or .docx
 
⁞ InstructionsChoose only ONE  of the following options .docx
⁞ InstructionsChoose only ONE  of the following options .docx⁞ InstructionsChoose only ONE  of the following options .docx
⁞ InstructionsChoose only ONE  of the following options .docx
 
⁞ InstructionsChoose only ONE of the following options below.docx
⁞ InstructionsChoose only ONE of the following options below.docx⁞ InstructionsChoose only ONE of the following options below.docx
⁞ InstructionsChoose only ONE of the following options below.docx
 
⁞ InstructionsAfter reading  The Metamorphosis by Frank .docx
⁞ InstructionsAfter reading  The Metamorphosis by Frank .docx⁞ InstructionsAfter reading  The Metamorphosis by Frank .docx
⁞ InstructionsAfter reading  The Metamorphosis by Frank .docx
 
⁞ InstructionsAfter reading all of Chapter 5, please se.docx
⁞ InstructionsAfter reading all of Chapter 5, please se.docx⁞ InstructionsAfter reading all of Chapter 5, please se.docx
⁞ InstructionsAfter reading all of Chapter 5, please se.docx
 
⁞ InstructionsAfter reading all of Chapter 2, please select.docx
⁞ InstructionsAfter reading all of Chapter 2, please select.docx⁞ InstructionsAfter reading all of Chapter 2, please select.docx
⁞ InstructionsAfter reading all of Chapter 2, please select.docx
 
⁞ Instructions After reading all of Chapter 9, please .docx
⁞ Instructions After reading all of Chapter 9, please .docx⁞ Instructions After reading all of Chapter 9, please .docx
⁞ Instructions After reading all of Chapter 9, please .docx
 
…Multiple intelligences describe an individual’s strengths or capac.docx
…Multiple intelligences describe an individual’s strengths or capac.docx…Multiple intelligences describe an individual’s strengths or capac.docx
…Multiple intelligences describe an individual’s strengths or capac.docx
 
••• JONATHAN LETHEM CRITICS OFTEN USE the word prolifi.docx
••• JONATHAN LETHEM CRITICS OFTEN USE the word prolifi.docx••• JONATHAN LETHEM CRITICS OFTEN USE the word prolifi.docx
••• JONATHAN LETHEM CRITICS OFTEN USE the word prolifi.docx
 
•••••iA National Profile ofthe Real Estate Industry and.docx
•••••iA National Profile ofthe Real Estate Industry and.docx•••••iA National Profile ofthe Real Estate Industry and.docx
•••••iA National Profile ofthe Real Estate Industry and.docx
 

Let us consider […] a pair of cases which I shall call Rescue .docx

Let us consider […] a pair of cases which I shall call Rescue .docx
Let us consider […] a pair of cases which I shall call Rescue .docx

Let us consider […] a pair of cases which I shall call Rescue .docx
 
•  Enhanced eText—Keeps students engaged in learning on th.docx
•  Enhanced eText—Keeps students engaged in learning on th.docx•  Enhanced eText—Keeps students engaged in learning on th.docx
•  Enhanced eText—Keeps students engaged in learning on th.docx
 
•    Here’s the approach you can take for this paperTitle.docx
•    Here’s the approach you can take for this paperTitle.docx•    Here’s the approach you can take for this paperTitle.docx
•    Here’s the approach you can take for this paperTitle.docx
 
•Your team will select a big data analytics project that is intr.docx
•Your team will select a big data analytics project that is intr.docx•Your team will select a big data analytics project that is intr.docx
•Your team will select a big data analytics project that is intr.docx
 

Recently uploaded

ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
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
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
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
 

Recently uploaded (20)

ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
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🔝
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
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
 

SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx

  • 1. 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: _______________________
  • 2. 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. 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 =
  • 4. 2 C3 = 3 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
  • 5. 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. 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.
  • 6. 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
  • 7. 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 γ
  • 8. 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
  • 9. 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
  • 10. 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
  • 11. 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
  • 12. 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
  • 13. 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
  • 14. 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)
  • 15. 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
  • 16. < 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 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
  • 17. % 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
  • 18. % 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]
  • 19. 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