SlideShare a Scribd company logo
1 of 14
Mechanical engineering assignment help
For any help regarding Matlab Assignment Help
visit : https://www.matlabassignmentexperts.com/ ,
Email info@matlabassignmentexperts.com or
call us at - +1 678 648 4277
matlabassignmentexperts.com
Problem 1 : Dynamics of a mass-spring-damper system
F t F0 sin t
k x
m
b x0 &v0
A mass-spring-damper system is subject to an external sinusoidal force F t with amplitude
F0 , and angular frequency  . The position of particle, x , is zero when the spring is neither
compressed or stretched. The mass of the particle is m , the damping coefficient is b and the spring constant is k . Initial
condition is expressed as x(0)  x0 and v(0)  v0 . Derive the equation of motion for this mass-spring-damper system.
Problem 2 : Solver for a mass-spring-damper system using Euler method
You are familiar with Euler method used to obtain the trajectory of a ball dropping and bouncing in Homework #3. In this
homework, you will create a function that use Euler method to derive the particle trajectory (two column matrix for time
and position each) in mass-spring-damper
system from t=0 to 50 sec. The input parameters of the function are coefficients ( m , b , k , F0
and  ) and initial conditions ( x0 and v0 ). Use time increment t  0.1sec . Function name (and m-file name) should be
‘MSDSE_your_kerberos_name’ and upload it to 2.003 MIT Server site. You also submit the hardcopy of your
code with appropriate comments.
Problems
matlabassignmentexperts.com
Problem 3 :
Solver for a mass-spring-damper system with using Runge-Kutta method
Using Runge-Kutta algorithm to solve the differential equation of this system, generate a m-file function with input parameters (
m , b , k , F0 ,  , x0 and v0 ) to calculate particle
trajectory (two column matrix for time and position each) from t=0 to 50 sec. You may use either Runge-Kutta 23 or 45 algorithm (See
ode23 or ode45 in the MATLAB help, and use one of them in your m-code.). Use t  0.1sec for both the time step size for the
solver (See also odeset
in the MATLAB help) and the time step for the output time from the solver (See input argument for
tspan in ode23 or ode45). Function name (and m-file name) should be
‘MSDSRK_your_kerberos_name’ and upload it to 2.003 MIT Server site. You also submit the hardcopy of your code with
appropriate comments.
Problem 4 : Trajectory of a mass-spring-damper system with different parameters and initial conditions
For the following cases, plot the time response of the particle. Plot the trajectories with Euler and Runge-Kutta solvers on a single
graph with appropriate legends. Compare the results for these two approaches. Submit a hardcopy of your trajectory plots.
i) m 1kg , b  0.5 Nsec/m , k 1 N/m , F0 1N ,   3 rad/sec , x(0)  0m and
v(0)  0m/ sec
ii) m 1kg , b  0.5 Nsec/m , k 1 N/m , F0  0N ,   0 rad/sec , x(0) 1m and
v(0)  0m/ sec
iii) m 1kg , b  0 Nsec/m , k 1 N/m , F0 1N ,  1 rad/sec , x(0)  0m and
v(0)  0m / sec
matlabassignmentexperts.com
Solutions
Problem 1 : Dynamics of mass-spring-damper system
From the above diagram,
Problem 2 : Solver for mass-spring-damper system with Euler method
First, 2nd order differential equation is split into two 1st order differential equations as did in
Homework #3.
matlabassignmentexperts.com
With Eq.(3), we also obtain the discrete version of above differential equations.
xn,1 x1 nt & xn,2 x2 nt
xn 1,1 xn,1 xn,2t xn 1,
2 xn,2 at
where
0
a 
1
F sinnt b xn,2 k  xn,1
m
The solver of mass-spring-damper system with Euler method is implemented as below. Explanation of each command line is
included in the following codes.
function O=MSDSE(m,b,k,F0,w,x0,v0)
%
% Solver for Mass-Sprring-Damper System with Euler Method
% ----- Input argument -----
% m: mass for particle
% b: damping coefficient
% k: spring constant
% F0: amplitude of external force
% w: angular freuency of external force
% x0: initial condition for the position x(0)
% v0: initial condition for the velocity v(0)
% ----- Output argument -----
% t: time series with given time step from ti to tf.
% x: state variable matrix for corresponding time t matrix
% Define time step in Euler method dt=0.1;
% Make time series with given time step t=[0:dt:50]';
% Initialize output matrix
% the 1st column: the position of the particle
% the 2nd column: the veleocity of the particle x=zeros(length(t),2);
% the 1st row has initial conditions x(1,:)=[x0 v0];
% Start the simulation with Euler method for i=1:length(t)-1
matlabassignmentexperts.com
% Apply Euler method
% x(n+1)=x(n)*v(n)*dt x(i+1,1,1)=x(i,1)+x(i,2)*dt;
% v(n+1)=v(n)*a(n)*dt
%where a(n)=1/m*(F0sin(wt)-bv(n)-kx(n))*dt x(i+1,2)=x(i,2)+(1/m)*(F0*sin(w*t(i))-b*x(i,2)-
k*x(i,1))*dt;
end
% Extract only particle position trajectory O=[t,x(:,1)];
end
Problem 3 : Solver for mass-spring-damper system with Runge-Kutta method
Unlike Euler method, you don’t need to solve differential equation itself in MATLAB. (You can also make your own code for Runge-Kutta algorithm
for yourself.) However, the subfunction should
be needed to implement Runge-Kutta algorithm. (Single m-file can have several functions. The
first one is the primary function, and others are subfunction.) Subfunction includes several 1st
order differential equations by splitting higher order
differential equation. In our case, two 1st
order equations are used as described in problem 6.2. With this subfunction, the solver (either
‘ode23’ or ‘ode45’) solves differential equations actually. The handler of function which has dynamic equation description, time span which
the solver calculates between, and initial condition at the simulation starting time are at least specified as the input arguments when the solver
runs. More detailed syntax description of either ‘ode23’ or ‘ode45’ is shown in MATLAB help. The solver of mass-spring-damper system
with Runge-Kutta method is implemented as below. Explanation of each command line is included in the following codes.
function O=MSDSRK(m,b,k,F0,w,x0,v0)
%
% Solver for Mass-Sprring-Damper System with Runge-Kutta Method
% ----- Input argument -----
% m: mass for particle
% b: damping coefficient
% k: spring constant
% F0: amplitude of external force
% w: angular freuency of external force
matlabassignmentexperts.com
% x0: initial condition for the position x(0)
% v0: initial condition for the velocity v(0)
% ----- Output argument -----
% t: time series with given time step from ti to tf.
% x: state variable matrix for corresponding time t matrix
% define time steps for solver and display dt=0.1;
% set both initial time step size and maximum step size
% for Runge-Kutta solver options=odeset('InitialStep',dt,'MaxStep',dt);
% set time span to be generated from Runge-Kutta solver
% from 0 sec to 50 sec with 0.1 sec time step td=[0:dt:50];
% Solve differential equation with Runge-Kutta solver
[t,x]=ode45(@(t,X)MSD(t,X,m,b,k,F0,w),td,[x0;v0],options);
% Extract only particle position trajectory O=[t x(:,1)];
end
function dX=MSD(t,X,m,b,k,F0,w)
%
% With two 1st order diffeential equations,
% obtain the derivative of each variables
% (position and velocity of the particle)
%
% t: current time
% X: matrix for state variables
% The first column : the particle position
% The second column : the particle velocity
% m,b,k,F0,w: parameters for the system
%
% Apply two 1st order differential equations
% dx(n+1)/dt<-v(n)
matlabassignmentexperts.com
dX(1,1)=X(2,1);
% dv(n+1)/dt<-1/m*(F0sin(wt)-bv(n)-kx(n))
dX(2,1)=(1/m)*(F0*sin(w*t)-b*X(2,1)-k*X(1,1)); end
Problem 4 : Trajectory of mss-spring-damper system with different parameters and initial conditions
i) Following code is used to generate below plot.
>> Oe=MSDSE(1,0.5,1,1,3,0,0);
>> Or=MSDSRK(1,0.5,1,1,3,0,0);
>> plot(Oe(:,1),Oe(:,2),'r',Or(:,1),Or(:,2),'b--','LineWidth',2); axis tight; grid on;
>> xlabel('bfTime (sec)'); ylabel('bfParticle Position (m)');
>> title({'bf Mass-Spring-Damper System Simulation'; 'm=1kg, b=0.5Nsec/m, k=1N/m, F_0=1m,
omega=3rad/sec, x_0=0m, & v_0=0m/sec'})
>> legend('bfEuler','bfRunge-Kutta','Location','NorthEast')
It’s the response of the sinusoidal excitation for the particle when it is stationary, and no spring is compressed or stretched. Comparing two
results from Euler method and Runge- Kutta method, they produce similar simulation results. The plot is shown as below:
matlabassignmentexperts.com
ii) Following code is use to generate below plot.
>> Oe=MSDSE(1,0.5,1,0,0,1,0);
>> Or=MSDSRK(1,0.5,1,0,0,1,0);
>> plot(Oe(:,1),Oe(:,2),'r',Or(:,1),Or(:,2),'b--','LineWidth',2); axis tight; grid on;
>> xlabel('bfTime (sec)'); ylabel('bfParticle Position (m)');
>> title({'bf Mass-Spring-Damper System Simulation'; 'm=1kg, b=0.5Nsec/m, k=1N/m, F_0=0m,
omega=0rad/sec, x_0=1m, & v_0=0m/sec'})
>> legend('bfEuler','bfRunge-Kutta','Location','NorthEast')
iii) Following code is use to generate below plot.
It’s the response with no external force and no damping when the spring is initially stretched. Comparing two results from Euler method and
Runge-Kutta method, Runge- Kutta method is more accurate than Euler method, based on the analytical solution of this system. The plot is
shown as below:1
>> Oe=MSDSE(1,0,1,1,1,0,0);
>> Or=MSDSRK(1,0,1,1,1,0,0);
>> plot(Oe(:,1),Oe(:,2),'r',Or(:,1),Or(:,2),'b--','LineWidth',2); axis tight; grid on;
matlabassignmentexperts.com
>> xlabel('bfTime (sec)'); ylabel('bfParticle Position (m)');
>> title({'bf Mass-Spring-Damper System Simulation'; 'm=1kg, b=0Nsec/m, k=1N/m, F_0=1m,
omega=1rad/sec, x_0=0m, & v_0=0m/sec'})
>> legend('bfEuler','bfRunge-Kutta','Location','NorthWest')
It’s the response of external force with the system resonance frequency when the spring is initially stretched. Resonance happens very quickly,
which means the particle position oscillates from  to  . However, numerical simulation has limitation to express the infinity. Therefore,
as time goes on, oscillations for both methods become larger, but Euler method one has smaller oscillation, compared with Runge-Kutta one.
So, Euler method is not powerful near the singularity. The plot is shown as below:
Mass-Spring-Damper System Simulation
m=1kg, b=0Nsec/m, k=1N/m, F0=1m, =1rad/sec, x0=0m, & v0=0m/sec
60
40
20
0
-20
-40
-60
-80
80
Particle
Position
(m)
Euler
Runge-Kutta
0 5 10 15 20 30 35 40 45 50
25
Time (sec)
matlabassignmentexperts.com
function O=MSDSE(m,b,k,F0,w,x0,v0)
%
% Solver for Mass-Sprring-Damper System with Euler Method
% ----- Input argument -----
% m: mass for particle
% b: damping coefficient
% k: spring constant
% F0: amplitude of external force
% w: angular freuency of external force
% x0: initial condition for the position x(0)
% v0: initial condition for the velocity v(0)
% ----- Output argument -----
% t: time series with given time step from ti to tf.
% x: state variable matrix for corresponding time t matrix
% Define time step in Euler method
dt=0.1;
% Make time series with given time step
t=[0:dt:50]';
% Initialize output matrix
% the 1st column: the position of the particle
% the 2nd column: the veleocity of the particle
x=zeros(length(t),2);
% the 1st row has initial conditions
x(1,:)=[x0 v0];
% Start the simulation with Euler method
matlabassignmentexperts.com
for i=1:length(t)-1
% Apply Euler method
% x(n+1)=x(n)*v(n)*dt
x(i+1,1,1)=x(i,1)+x(i,2)*dt;
% v(n+1)=v(n)*a(n)*dt
%where a(n)=1/m*(F0sin(wt)-bv(n)-kx(n))*dt
x(i+1,2)=x(i,2)+(1/m)*(F0*sin(w*t(i))-b*x(i,2)-k*x(i,1))*dt;
end
% Extract only particle position trajectory
O=[t,x(:,1)];
end
function O=MSDSRK(m,b,k,F0,w,x0,v0)
%
% Solver for Mass-Sprring-Damper System with Runge-Kutta Method
% ----- Input argument -----
% m: mass for particle
% b: damping coefficient
% k: spring constant
% F0: amplitude of external force
% w: angular freuency of external force
% x0: initial condition for the position x(0)
% v0: initial condition for the velocity v(0)
% ----- Output argument -----
% t: time series with given time step from ti to tf.
% x: state variable matrix for corresponding time t matrix
matlabassignmentexperts.com
% define time steps for solver and display
dt=0.1;
% set both initial time step size and maximum step size
% for Runge-Kutta solver
options=odeset('InitialStep',dt,'MaxStep',dt);
% set time span to be generated from Runge-Kutta solver
% from 0 sec to 50 sec with 0.1 sec time step
td=[0:dt:50];
% Solve differential equation with Runge-Kutta solver
[t,x]=ode45(@(t,X)MSD(t,X,m,b,k,F0,w),td,[x0;v0],options);
% Extract only particle position trajectory
O=[t x(:,1)];
end
function dX=MSD(t,X,m,b,k,F0,w)
%
% With two 1st order diffeential equations,
% obtain the derivative of each variables
% (position and velocity of the particle)
%
% t: current time
% X: matrix for state variables
% The first column : the particle position
% The second column : the particle velocity
% m,b,k,F0,w: parameters for the system
%
matlabassignmentexperts.com
% Apply two 1st order differential equations
% dx(n+1)/dt<-v(n)
dX(1,1)=X(2,1);
% dv(n+1)/dt<-1/m*(F0sin(wt)-bv(n)-kx(n))
dX(2,1)=(1/m)*(F0*sin(w*t)-b*X(2,1)-k*X(1,1));
end
matlabassignmentexperts.com

More Related Content

What's hot

process control
process controlprocess control
process controlAamir Khan
 
1.Humidification-Lec. 1.pptx
1.Humidification-Lec. 1.pptx1.Humidification-Lec. 1.pptx
1.Humidification-Lec. 1.pptxTaqqiHaider
 
McCABE-THIELE DESIGN METHOD
McCABE-THIELE DESIGN METHODMcCABE-THIELE DESIGN METHOD
McCABE-THIELE DESIGN METHODMeet Patel
 
heat diffusion equation.ppt
heat diffusion equation.pptheat diffusion equation.ppt
heat diffusion equation.ppt056JatinGavel
 
Material balance with chemical reaction
Material balance with chemical reactionMaterial balance with chemical reaction
Material balance with chemical reactionJayJawalge
 
TOPIC 3.1 - Flow Measurement.pptx
TOPIC 3.1 - Flow Measurement.pptxTOPIC 3.1 - Flow Measurement.pptx
TOPIC 3.1 - Flow Measurement.pptxQurratuAini76
 
Pitot tube, anemometer and their types
Pitot tube, anemometer and their typesPitot tube, anemometer and their types
Pitot tube, anemometer and their typesYokeshDhanabal
 
IRJET- A Literature Review on Investigation of Design Parameter of Cyclone Se...
IRJET- A Literature Review on Investigation of Design Parameter of Cyclone Se...IRJET- A Literature Review on Investigation of Design Parameter of Cyclone Se...
IRJET- A Literature Review on Investigation of Design Parameter of Cyclone Se...IRJET Journal
 
LEACHING CONCEPT, TECHNIQUE AND SINGLE AND MULTISTAGE LEACHING
LEACHING CONCEPT, TECHNIQUE AND SINGLE AND MULTISTAGE LEACHINGLEACHING CONCEPT, TECHNIQUE AND SINGLE AND MULTISTAGE LEACHING
LEACHING CONCEPT, TECHNIQUE AND SINGLE AND MULTISTAGE LEACHINGKrishna Peshivadiya
 
Time response analysis of system
Time response analysis of systemTime response analysis of system
Time response analysis of systemvishalgohel12195
 
Analysis and Design of PID controller with control parameters in MATLAB and S...
Analysis and Design of PID controller with control parameters in MATLAB and S...Analysis and Design of PID controller with control parameters in MATLAB and S...
Analysis and Design of PID controller with control parameters in MATLAB and S...MIbrar4
 
Tank in series model
Tank in series modelTank in series model
Tank in series modelSunny Chauhan
 

What's hot (20)

Mass transfer
Mass transferMass transfer
Mass transfer
 
process control
process controlprocess control
process control
 
Non ideal flow
Non ideal flowNon ideal flow
Non ideal flow
 
1.Humidification-Lec. 1.pptx
1.Humidification-Lec. 1.pptx1.Humidification-Lec. 1.pptx
1.Humidification-Lec. 1.pptx
 
2.2 McCabe-Thiele method
2.2 McCabe-Thiele method2.2 McCabe-Thiele method
2.2 McCabe-Thiele method
 
McCABE-THIELE DESIGN METHOD
McCABE-THIELE DESIGN METHODMcCABE-THIELE DESIGN METHOD
McCABE-THIELE DESIGN METHOD
 
heat diffusion equation.ppt
heat diffusion equation.pptheat diffusion equation.ppt
heat diffusion equation.ppt
 
Material balance with chemical reaction
Material balance with chemical reactionMaterial balance with chemical reaction
Material balance with chemical reaction
 
Chap1
Chap1Chap1
Chap1
 
Transport phenomena
Transport phenomenaTransport phenomena
Transport phenomena
 
TOPIC 3.1 - Flow Measurement.pptx
TOPIC 3.1 - Flow Measurement.pptxTOPIC 3.1 - Flow Measurement.pptx
TOPIC 3.1 - Flow Measurement.pptx
 
Pitot tube, anemometer and their types
Pitot tube, anemometer and their typesPitot tube, anemometer and their types
Pitot tube, anemometer and their types
 
Manometer
ManometerManometer
Manometer
 
IRJET- A Literature Review on Investigation of Design Parameter of Cyclone Se...
IRJET- A Literature Review on Investigation of Design Parameter of Cyclone Se...IRJET- A Literature Review on Investigation of Design Parameter of Cyclone Se...
IRJET- A Literature Review on Investigation of Design Parameter of Cyclone Se...
 
Flash distillation
Flash distillationFlash distillation
Flash distillation
 
Flow measurement questions
Flow measurement questionsFlow measurement questions
Flow measurement questions
 
LEACHING CONCEPT, TECHNIQUE AND SINGLE AND MULTISTAGE LEACHING
LEACHING CONCEPT, TECHNIQUE AND SINGLE AND MULTISTAGE LEACHINGLEACHING CONCEPT, TECHNIQUE AND SINGLE AND MULTISTAGE LEACHING
LEACHING CONCEPT, TECHNIQUE AND SINGLE AND MULTISTAGE LEACHING
 
Time response analysis of system
Time response analysis of systemTime response analysis of system
Time response analysis of system
 
Analysis and Design of PID controller with control parameters in MATLAB and S...
Analysis and Design of PID controller with control parameters in MATLAB and S...Analysis and Design of PID controller with control parameters in MATLAB and S...
Analysis and Design of PID controller with control parameters in MATLAB and S...
 
Tank in series model
Tank in series modelTank in series model
Tank in series model
 

Similar to Mechanical Engineering Assignment Help

From the Front LinesOur robotic equipment and its maintenanc.docx
From the Front LinesOur robotic equipment and its maintenanc.docxFrom the Front LinesOur robotic equipment and its maintenanc.docx
From the Front LinesOur robotic equipment and its maintenanc.docxhanneloremccaffery
 
Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docxLab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docxsmile790243
 
ENGINEERING SYSTEM DYNAMICS-TAKE HOME ASSIGNMENT 2018
ENGINEERING SYSTEM DYNAMICS-TAKE HOME ASSIGNMENT 2018ENGINEERING SYSTEM DYNAMICS-TAKE HOME ASSIGNMENT 2018
ENGINEERING SYSTEM DYNAMICS-TAKE HOME ASSIGNMENT 2018musadoto
 
MATLAB ODE
MATLAB ODEMATLAB ODE
MATLAB ODEKris014
 
Applications Section 1.3
Applications   Section 1.3Applications   Section 1.3
Applications Section 1.3mobart02
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxanhlodge
 
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
 
Comparisons
ComparisonsComparisons
ComparisonsZifirio
 
Comparisons
ComparisonsComparisons
ComparisonsZifirio
 
Comparisons
ComparisonsComparisons
ComparisonsZifirio
 
Comparisons
ComparisonsComparisons
ComparisonsZifirio
 
Comparisons
ComparisonsComparisons
ComparisonsZifirio
 
Comparisons
ComparisonsComparisons
ComparisonsZifirio
 
Comparisons
ComparisonsComparisons
ComparisonsZifirio
 
Comparisons
ComparisonsComparisons
ComparisonsZifirio
 
Comparisons
ComparisonsComparisons
ComparisonsZifirio
 
Comparisons
ComparisonsComparisons
ComparisonsZifirio
 
Comparisons
ComparisonsComparisons
ComparisonsZifirio
 

Similar to Mechanical Engineering Assignment Help (20)

From the Front LinesOur robotic equipment and its maintenanc.docx
From the Front LinesOur robotic equipment and its maintenanc.docxFrom the Front LinesOur robotic equipment and its maintenanc.docx
From the Front LinesOur robotic equipment and its maintenanc.docx
 
Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docxLab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx
 
ENGINEERING SYSTEM DYNAMICS-TAKE HOME ASSIGNMENT 2018
ENGINEERING SYSTEM DYNAMICS-TAKE HOME ASSIGNMENT 2018ENGINEERING SYSTEM DYNAMICS-TAKE HOME ASSIGNMENT 2018
ENGINEERING SYSTEM DYNAMICS-TAKE HOME ASSIGNMENT 2018
 
MATLAB ODE
MATLAB ODEMATLAB ODE
MATLAB ODE
 
Chapter26
Chapter26Chapter26
Chapter26
 
Applications Section 1.3
Applications   Section 1.3Applications   Section 1.3
Applications Section 1.3
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
 
Quality Python Homework Help
Quality Python Homework HelpQuality Python Homework Help
Quality Python Homework Help
 
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
 
Comparisons
ComparisonsComparisons
Comparisons
 
Comparisons
ComparisonsComparisons
Comparisons
 
Comparisons
ComparisonsComparisons
Comparisons
 
Comparisons
ComparisonsComparisons
Comparisons
 
Comparisons
ComparisonsComparisons
Comparisons
 
Comparisons
ComparisonsComparisons
Comparisons
 
Comparisons
ComparisonsComparisons
Comparisons
 
Comparisons
ComparisonsComparisons
Comparisons
 
Comparisons
ComparisonsComparisons
Comparisons
 
Comparisons
ComparisonsComparisons
Comparisons
 
Comparisons
ComparisonsComparisons
Comparisons
 

More from Matlab Assignment Experts

🚀 Need Expert MATLAB Assignment Help? Look No Further! 📊
🚀 Need Expert MATLAB Assignment Help? Look No Further! 📊🚀 Need Expert MATLAB Assignment Help? Look No Further! 📊
🚀 Need Expert MATLAB Assignment Help? Look No Further! 📊Matlab Assignment Experts
 

More from Matlab Assignment Experts (20)

🚀 Need Expert MATLAB Assignment Help? Look No Further! 📊
🚀 Need Expert MATLAB Assignment Help? Look No Further! 📊🚀 Need Expert MATLAB Assignment Help? Look No Further! 📊
🚀 Need Expert MATLAB Assignment Help? Look No Further! 📊
 
Matlab Assignment Help
Matlab Assignment HelpMatlab Assignment Help
Matlab Assignment Help
 
Matlab Assignment Help
Matlab Assignment HelpMatlab Assignment Help
Matlab Assignment Help
 
Matlab Assignment Help
Matlab Assignment HelpMatlab Assignment Help
Matlab Assignment Help
 
MAtlab Assignment Help
MAtlab Assignment HelpMAtlab Assignment Help
MAtlab Assignment Help
 
Matlab Assignment Help
Matlab Assignment HelpMatlab Assignment Help
Matlab Assignment Help
 
Matlab Assignment Help
Matlab Assignment HelpMatlab Assignment Help
Matlab Assignment Help
 
Matlab Homework Help
Matlab Homework HelpMatlab Homework Help
Matlab Homework Help
 
MATLAB Assignment Help
MATLAB Assignment HelpMATLAB Assignment Help
MATLAB Assignment Help
 
Matlab Homework Help
Matlab Homework HelpMatlab Homework Help
Matlab Homework Help
 
Matlab Assignment Help
Matlab Assignment HelpMatlab Assignment Help
Matlab Assignment Help
 
Computer vision (Matlab)
Computer vision (Matlab)Computer vision (Matlab)
Computer vision (Matlab)
 
Online Matlab Assignment Help
Online Matlab Assignment HelpOnline Matlab Assignment Help
Online Matlab Assignment Help
 
Modelling & Simulation Assignment Help
Modelling & Simulation Assignment HelpModelling & Simulation Assignment Help
Modelling & Simulation Assignment Help
 
Mechanical Assignment Help
Mechanical Assignment HelpMechanical Assignment Help
Mechanical Assignment Help
 
CURVE FITING ASSIGNMENT HELP
CURVE FITING ASSIGNMENT HELPCURVE FITING ASSIGNMENT HELP
CURVE FITING ASSIGNMENT HELP
 
Design and Manufacturing Homework Help
Design and Manufacturing Homework HelpDesign and Manufacturing Homework Help
Design and Manufacturing Homework Help
 
Digital Image Processing Assignment Help
Digital Image Processing Assignment HelpDigital Image Processing Assignment Help
Digital Image Processing Assignment Help
 
Signals and Systems Assignment Help
Signals and Systems Assignment HelpSignals and Systems Assignment Help
Signals and Systems Assignment Help
 
Signal Processing Assignment Help
Signal Processing Assignment HelpSignal Processing Assignment Help
Signal Processing Assignment Help
 

Recently uploaded

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 

Recently uploaded (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 

Mechanical Engineering Assignment Help

  • 1. Mechanical engineering assignment help For any help regarding Matlab Assignment Help visit : https://www.matlabassignmentexperts.com/ , Email info@matlabassignmentexperts.com or call us at - +1 678 648 4277 matlabassignmentexperts.com
  • 2. Problem 1 : Dynamics of a mass-spring-damper system F t F0 sin t k x m b x0 &v0 A mass-spring-damper system is subject to an external sinusoidal force F t with amplitude F0 , and angular frequency  . The position of particle, x , is zero when the spring is neither compressed or stretched. The mass of the particle is m , the damping coefficient is b and the spring constant is k . Initial condition is expressed as x(0)  x0 and v(0)  v0 . Derive the equation of motion for this mass-spring-damper system. Problem 2 : Solver for a mass-spring-damper system using Euler method You are familiar with Euler method used to obtain the trajectory of a ball dropping and bouncing in Homework #3. In this homework, you will create a function that use Euler method to derive the particle trajectory (two column matrix for time and position each) in mass-spring-damper system from t=0 to 50 sec. The input parameters of the function are coefficients ( m , b , k , F0 and  ) and initial conditions ( x0 and v0 ). Use time increment t  0.1sec . Function name (and m-file name) should be ‘MSDSE_your_kerberos_name’ and upload it to 2.003 MIT Server site. You also submit the hardcopy of your code with appropriate comments. Problems matlabassignmentexperts.com
  • 3. Problem 3 : Solver for a mass-spring-damper system with using Runge-Kutta method Using Runge-Kutta algorithm to solve the differential equation of this system, generate a m-file function with input parameters ( m , b , k , F0 ,  , x0 and v0 ) to calculate particle trajectory (two column matrix for time and position each) from t=0 to 50 sec. You may use either Runge-Kutta 23 or 45 algorithm (See ode23 or ode45 in the MATLAB help, and use one of them in your m-code.). Use t  0.1sec for both the time step size for the solver (See also odeset in the MATLAB help) and the time step for the output time from the solver (See input argument for tspan in ode23 or ode45). Function name (and m-file name) should be ‘MSDSRK_your_kerberos_name’ and upload it to 2.003 MIT Server site. You also submit the hardcopy of your code with appropriate comments. Problem 4 : Trajectory of a mass-spring-damper system with different parameters and initial conditions For the following cases, plot the time response of the particle. Plot the trajectories with Euler and Runge-Kutta solvers on a single graph with appropriate legends. Compare the results for these two approaches. Submit a hardcopy of your trajectory plots. i) m 1kg , b  0.5 Nsec/m , k 1 N/m , F0 1N ,   3 rad/sec , x(0)  0m and v(0)  0m/ sec ii) m 1kg , b  0.5 Nsec/m , k 1 N/m , F0  0N ,   0 rad/sec , x(0) 1m and v(0)  0m/ sec iii) m 1kg , b  0 Nsec/m , k 1 N/m , F0 1N ,  1 rad/sec , x(0)  0m and v(0)  0m / sec matlabassignmentexperts.com
  • 4. Solutions Problem 1 : Dynamics of mass-spring-damper system From the above diagram, Problem 2 : Solver for mass-spring-damper system with Euler method First, 2nd order differential equation is split into two 1st order differential equations as did in Homework #3. matlabassignmentexperts.com
  • 5. With Eq.(3), we also obtain the discrete version of above differential equations. xn,1 x1 nt & xn,2 x2 nt xn 1,1 xn,1 xn,2t xn 1, 2 xn,2 at where 0 a  1 F sinnt b xn,2 k  xn,1 m The solver of mass-spring-damper system with Euler method is implemented as below. Explanation of each command line is included in the following codes. function O=MSDSE(m,b,k,F0,w,x0,v0) % % Solver for Mass-Sprring-Damper System with Euler Method % ----- Input argument ----- % m: mass for particle % b: damping coefficient % k: spring constant % F0: amplitude of external force % w: angular freuency of external force % x0: initial condition for the position x(0) % v0: initial condition for the velocity v(0) % ----- Output argument ----- % t: time series with given time step from ti to tf. % x: state variable matrix for corresponding time t matrix % Define time step in Euler method dt=0.1; % Make time series with given time step t=[0:dt:50]'; % Initialize output matrix % the 1st column: the position of the particle % the 2nd column: the veleocity of the particle x=zeros(length(t),2); % the 1st row has initial conditions x(1,:)=[x0 v0]; % Start the simulation with Euler method for i=1:length(t)-1 matlabassignmentexperts.com
  • 6. % Apply Euler method % x(n+1)=x(n)*v(n)*dt x(i+1,1,1)=x(i,1)+x(i,2)*dt; % v(n+1)=v(n)*a(n)*dt %where a(n)=1/m*(F0sin(wt)-bv(n)-kx(n))*dt x(i+1,2)=x(i,2)+(1/m)*(F0*sin(w*t(i))-b*x(i,2)- k*x(i,1))*dt; end % Extract only particle position trajectory O=[t,x(:,1)]; end Problem 3 : Solver for mass-spring-damper system with Runge-Kutta method Unlike Euler method, you don’t need to solve differential equation itself in MATLAB. (You can also make your own code for Runge-Kutta algorithm for yourself.) However, the subfunction should be needed to implement Runge-Kutta algorithm. (Single m-file can have several functions. The first one is the primary function, and others are subfunction.) Subfunction includes several 1st order differential equations by splitting higher order differential equation. In our case, two 1st order equations are used as described in problem 6.2. With this subfunction, the solver (either ‘ode23’ or ‘ode45’) solves differential equations actually. The handler of function which has dynamic equation description, time span which the solver calculates between, and initial condition at the simulation starting time are at least specified as the input arguments when the solver runs. More detailed syntax description of either ‘ode23’ or ‘ode45’ is shown in MATLAB help. The solver of mass-spring-damper system with Runge-Kutta method is implemented as below. Explanation of each command line is included in the following codes. function O=MSDSRK(m,b,k,F0,w,x0,v0) % % Solver for Mass-Sprring-Damper System with Runge-Kutta Method % ----- Input argument ----- % m: mass for particle % b: damping coefficient % k: spring constant % F0: amplitude of external force % w: angular freuency of external force matlabassignmentexperts.com
  • 7. % x0: initial condition for the position x(0) % v0: initial condition for the velocity v(0) % ----- Output argument ----- % t: time series with given time step from ti to tf. % x: state variable matrix for corresponding time t matrix % define time steps for solver and display dt=0.1; % set both initial time step size and maximum step size % for Runge-Kutta solver options=odeset('InitialStep',dt,'MaxStep',dt); % set time span to be generated from Runge-Kutta solver % from 0 sec to 50 sec with 0.1 sec time step td=[0:dt:50]; % Solve differential equation with Runge-Kutta solver [t,x]=ode45(@(t,X)MSD(t,X,m,b,k,F0,w),td,[x0;v0],options); % Extract only particle position trajectory O=[t x(:,1)]; end function dX=MSD(t,X,m,b,k,F0,w) % % With two 1st order diffeential equations, % obtain the derivative of each variables % (position and velocity of the particle) % % t: current time % X: matrix for state variables % The first column : the particle position % The second column : the particle velocity % m,b,k,F0,w: parameters for the system % % Apply two 1st order differential equations % dx(n+1)/dt<-v(n) matlabassignmentexperts.com
  • 8. dX(1,1)=X(2,1); % dv(n+1)/dt<-1/m*(F0sin(wt)-bv(n)-kx(n)) dX(2,1)=(1/m)*(F0*sin(w*t)-b*X(2,1)-k*X(1,1)); end Problem 4 : Trajectory of mss-spring-damper system with different parameters and initial conditions i) Following code is used to generate below plot. >> Oe=MSDSE(1,0.5,1,1,3,0,0); >> Or=MSDSRK(1,0.5,1,1,3,0,0); >> plot(Oe(:,1),Oe(:,2),'r',Or(:,1),Or(:,2),'b--','LineWidth',2); axis tight; grid on; >> xlabel('bfTime (sec)'); ylabel('bfParticle Position (m)'); >> title({'bf Mass-Spring-Damper System Simulation'; 'm=1kg, b=0.5Nsec/m, k=1N/m, F_0=1m, omega=3rad/sec, x_0=0m, & v_0=0m/sec'}) >> legend('bfEuler','bfRunge-Kutta','Location','NorthEast') It’s the response of the sinusoidal excitation for the particle when it is stationary, and no spring is compressed or stretched. Comparing two results from Euler method and Runge- Kutta method, they produce similar simulation results. The plot is shown as below: matlabassignmentexperts.com
  • 9. ii) Following code is use to generate below plot. >> Oe=MSDSE(1,0.5,1,0,0,1,0); >> Or=MSDSRK(1,0.5,1,0,0,1,0); >> plot(Oe(:,1),Oe(:,2),'r',Or(:,1),Or(:,2),'b--','LineWidth',2); axis tight; grid on; >> xlabel('bfTime (sec)'); ylabel('bfParticle Position (m)'); >> title({'bf Mass-Spring-Damper System Simulation'; 'm=1kg, b=0.5Nsec/m, k=1N/m, F_0=0m, omega=0rad/sec, x_0=1m, & v_0=0m/sec'}) >> legend('bfEuler','bfRunge-Kutta','Location','NorthEast') iii) Following code is use to generate below plot. It’s the response with no external force and no damping when the spring is initially stretched. Comparing two results from Euler method and Runge-Kutta method, Runge- Kutta method is more accurate than Euler method, based on the analytical solution of this system. The plot is shown as below:1 >> Oe=MSDSE(1,0,1,1,1,0,0); >> Or=MSDSRK(1,0,1,1,1,0,0); >> plot(Oe(:,1),Oe(:,2),'r',Or(:,1),Or(:,2),'b--','LineWidth',2); axis tight; grid on; matlabassignmentexperts.com
  • 10. >> xlabel('bfTime (sec)'); ylabel('bfParticle Position (m)'); >> title({'bf Mass-Spring-Damper System Simulation'; 'm=1kg, b=0Nsec/m, k=1N/m, F_0=1m, omega=1rad/sec, x_0=0m, & v_0=0m/sec'}) >> legend('bfEuler','bfRunge-Kutta','Location','NorthWest') It’s the response of external force with the system resonance frequency when the spring is initially stretched. Resonance happens very quickly, which means the particle position oscillates from  to  . However, numerical simulation has limitation to express the infinity. Therefore, as time goes on, oscillations for both methods become larger, but Euler method one has smaller oscillation, compared with Runge-Kutta one. So, Euler method is not powerful near the singularity. The plot is shown as below: Mass-Spring-Damper System Simulation m=1kg, b=0Nsec/m, k=1N/m, F0=1m, =1rad/sec, x0=0m, & v0=0m/sec 60 40 20 0 -20 -40 -60 -80 80 Particle Position (m) Euler Runge-Kutta 0 5 10 15 20 30 35 40 45 50 25 Time (sec) matlabassignmentexperts.com
  • 11. function O=MSDSE(m,b,k,F0,w,x0,v0) % % Solver for Mass-Sprring-Damper System with Euler Method % ----- Input argument ----- % m: mass for particle % b: damping coefficient % k: spring constant % F0: amplitude of external force % w: angular freuency of external force % x0: initial condition for the position x(0) % v0: initial condition for the velocity v(0) % ----- Output argument ----- % t: time series with given time step from ti to tf. % x: state variable matrix for corresponding time t matrix % Define time step in Euler method dt=0.1; % Make time series with given time step t=[0:dt:50]'; % Initialize output matrix % the 1st column: the position of the particle % the 2nd column: the veleocity of the particle x=zeros(length(t),2); % the 1st row has initial conditions x(1,:)=[x0 v0]; % Start the simulation with Euler method matlabassignmentexperts.com
  • 12. for i=1:length(t)-1 % Apply Euler method % x(n+1)=x(n)*v(n)*dt x(i+1,1,1)=x(i,1)+x(i,2)*dt; % v(n+1)=v(n)*a(n)*dt %where a(n)=1/m*(F0sin(wt)-bv(n)-kx(n))*dt x(i+1,2)=x(i,2)+(1/m)*(F0*sin(w*t(i))-b*x(i,2)-k*x(i,1))*dt; end % Extract only particle position trajectory O=[t,x(:,1)]; end function O=MSDSRK(m,b,k,F0,w,x0,v0) % % Solver for Mass-Sprring-Damper System with Runge-Kutta Method % ----- Input argument ----- % m: mass for particle % b: damping coefficient % k: spring constant % F0: amplitude of external force % w: angular freuency of external force % x0: initial condition for the position x(0) % v0: initial condition for the velocity v(0) % ----- Output argument ----- % t: time series with given time step from ti to tf. % x: state variable matrix for corresponding time t matrix matlabassignmentexperts.com
  • 13. % define time steps for solver and display dt=0.1; % set both initial time step size and maximum step size % for Runge-Kutta solver options=odeset('InitialStep',dt,'MaxStep',dt); % set time span to be generated from Runge-Kutta solver % from 0 sec to 50 sec with 0.1 sec time step td=[0:dt:50]; % Solve differential equation with Runge-Kutta solver [t,x]=ode45(@(t,X)MSD(t,X,m,b,k,F0,w),td,[x0;v0],options); % Extract only particle position trajectory O=[t x(:,1)]; end function dX=MSD(t,X,m,b,k,F0,w) % % With two 1st order diffeential equations, % obtain the derivative of each variables % (position and velocity of the particle) % % t: current time % X: matrix for state variables % The first column : the particle position % The second column : the particle velocity % m,b,k,F0,w: parameters for the system % matlabassignmentexperts.com
  • 14. % Apply two 1st order differential equations % dx(n+1)/dt<-v(n) dX(1,1)=X(2,1); % dv(n+1)/dt<-1/m*(F0sin(wt)-bv(n)-kx(n)) dX(2,1)=(1/m)*(F0*sin(w*t)-b*X(2,1)-k*X(1,1)); end matlabassignmentexperts.com