






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Problem 4 (4 Points): Create a MATLAB script file that uses the Euler Method discussed in class to solve the following differential equation. Plot the solution ...
Typology: Study notes
1 / 10
This page cannot be seen from the preview
Don't miss anything!







Wright State University Spring 2016
Department of Mechanical and Materials Engineering
Open Book, Closed Notes, Do Not Write on this Sheet
Create a Separate MATLAB Script File for Each Problem
Submit all MATLAB files (.m) to Dr. Thomas
Each MATLAB File Must Have the Following Header:
Problem 1 ( 4 Points): Create a MATLAB script file to calculate and plot the derivative of the function ๐ฆ
โ๐ฅ
sin( 3 ๐ฅ) from 0 โค ๐ฅ โค 4 using the Forward Difference Method described in class (shown below). You must
use a for loop to solve this problem. Provide a plot title and labels for the axes. Use 101 points from ๐ฅ = 0 to
Problem 2 ( 4 Points): Create a MATLAB script file to calculate and plot the integral of the function ๐ฆ
โ๐ฅ
sin( 3 ๐ฅ) from 0 โค ๐ฅ โค 4 using the Trapezoidal Method described in class (shown below). You must use a
for loop to solve this problem. Provide a plot title and labels for the axes. Use 101 points from ๐ฅ = 0 to ๐ฅ = 4.
trapezoid
2
1
1
2
Problem 3 ( 4 Points): Create a MATLAB script file that uses the Euler Method discussed in class to solve the
following differential equation. Plot the solution from 0 โค ๐ก โค 0. 2. Provide a plot title and labels for the axes.
You must use a for loop to solve this problem. Show that ๐ฆ
3 / 2
Euler Method: ๐ฆ(๐ก
๐+ 1
๐
๐
๐
Problem 4 ( 4 Points): Create a MATLAB script file that uses the Euler Method discussed in class to solve the
following differential equation. Plot the solution from 0 โค ๐ก โค 0. 2. Provide a plot title and labels for the axes.
You must use a for loop to solve this problem. Show that ๐ฆ(๐ก = 0. 2 ) = 3. 1359.
3 / 2
Euler Method: ๐ฆ(๐ก
๐+ 1
๐
๐
๐
Problem 5 ( 4 Points): Create a MATLAB SIMULINK model to solve the following differential equation. Plot
the solution from 0 โค ๐ก โค 0. 2.
3 / 2
% Final Exam, ME 1020, Spring 2016, Your Name Here
% Problem 2
clc, clear all, close all
N = 101;
x = linspace(0,4,N);
y = exp(-x).sin(3x);
inty(1) = 0;
for k = 1:N- 1
inty(k+1) = inty(k) + 0.5(x(k+1)-x(k))(y(k)+y(k+1));
end
plot(x,y,x,inty)
xlabel('x'),ylabel('y(x) and int y(x)')
title('Problem 2: Scott Thomas')
legend('y(x)','int y(x)','Location','Best')
Published with MATLABยฎ R2012b
% Final Exam, ME 1020, Spring 2016, Your Name Here
% Problem 3
clc, clear all, close all
N = 500000
tfinal = 0.2;
deltat = tfinal/(N-1);
y(1) = 3;
t(1) = 0;
for k = 1:N- 1
y(k+1) = y(k) + deltat*((y(k))^(3/2) + 2);
t(k+1) = t(k) + deltat;
end
t(N)
y(N)
plot(t,y)
xlabel('t'),ylabel('y(t)')
title('Problem 3: Scott Thomas')
N =
500000
ans =
ans =
% Final Exam, ME 1020, Spring 2016, Your Name Here
% Problem 4
clc, clear all, close all
N = 50000
tfinal = 0.2;
deltat = tfinal/(N-1);
x1(1) = 3;
x2(1) = 0;
t(1) = 0;
for k = 1:N- 1
x1(k+1) = x1(k) + deltat*x2(k);
x2(k+1) = x2(k) + deltat*(-x2(k) + (x1(k))^(3/2) + 2);
t(k+1) = t(k) + deltat;
end
t(N)
x1(N)
plot(t,x1)
xlabel('t'),ylabel('y(t)')
title('Problem 4: Scott Thomas')
N =
50000
ans =
ans =
Published with MATLABยฎ R2012b