ENGINEERING PROGRAMMING WITH MATLAB FINAL EXAM, Study notes of Engineering

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

2021/2022

Uploaded on 08/01/2022

fioh_ji
fioh_ji ๐Ÿ‡ฐ๐Ÿ‡ผ

4.5

(70)

814 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Wright State University Spring 2016
Department of Mechanical and Materials Engineering
ME 1020: ENGINEERING PROGRAMMING WITH MATLAB
FINAL EXAM
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
๐‘ฅ = 4.
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 =1
2(๐‘ฅ2โˆ’ ๐‘ฅ1)(๐‘ฆ1+ ๐‘ฆ2)
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download ENGINEERING PROGRAMMING WITH MATLAB FINAL EXAM and more Study notes Engineering in PDF only on Docsity!

Wright State University Spring 2016

Department of Mechanical and Materials Engineering

ME 1020: ENGINEERING PROGRAMMING WITH MATLAB

FINAL EXAM

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