0% found this document useful (0 votes)
104 views3 pages

MATLAB Lab: Engineering Modeling Tasks

The document outlines the requirements for Computer Lab #1 in the MECH 2150 course, focusing on MATLAB programming tasks. Students are to create three MATLAB script files to plot data related to photodegradation, analyze beam deflection under load, and evaluate a function using an infinite series. Submission of the three m-files is required by the due date of September 19th, 2025.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views3 pages

MATLAB Lab: Engineering Modeling Tasks

The document outlines the requirements for Computer Lab #1 in the MECH 2150 course, focusing on MATLAB programming tasks. Students are to create three MATLAB script files to plot data related to photodegradation, analyze beam deflection under load, and evaluate a function using an infinite series. Submission of the three m-files is required by the due date of September 19th, 2025.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MECH 2150 Mechanical Engineering Modelling and Numerical Methods Fall 2025

Computer Lab #1 – Introduction to MATLAB


Due: Friday, September 19th at 11:59pm

1. Problem 2.16 in Chapra [1]

It is general practice in engineering and science that equations be plotted as lines and discrete
data as symbols. Here is some data for concentration (𝑐) versus time (𝑡) for the photodegradation
of aqueous bromine:

𝑡 (min) 10 20 30 40 50 60
𝑐 (ppm) 3.4 2.6 1.6 1.3 1.0 0.5

These data can be described by the following function:


.
𝑐 = 4.84𝑒
Create a MATLAB script file called Lab1Q1.m that creates a plot displaying both the data (using
diamond-shaped, red symbols) and the function (using a blue, dashed line). Create the function
as an anonymous function and use fplot to plot it from 𝑡 = 0 to 70 min. Include axes labels and a
title for the plot.
Notes:

 Use the hold on command to keep a figure open and plot again on that same figure.
 Include the clear and clc commands as the first two lines of your code.
 Include comments throughout the script file.

1
MECH 2150 Mechanical Engineering Modelling and Numerical Methods Fall 2025

2. Problem 2.26 in Chapra [1]

Figure 2.26 shows a uniform beam subject to a linearly increasing distributed load.

Figure 2.26
As depicted in the figure, the deflection 𝑦 can be computed as:
𝑤
𝑦= (−𝑥 + 2𝐿 𝑥 − 𝐿 𝑥)
120𝐸𝐼𝐿
Where 𝐸 = the modulus of elasticity and 𝐼 = the moment of inertia. Employ this equation and
calculus to create a MATLAB script m-file called Lab1Q2.m that generates plots of the following
quantities versus distance along the beam:
a) Displacement (𝑦)
b) Slope (𝜃(𝑥) = 𝑑𝑦/𝑑𝑥)
c) Moment (𝑀(𝑥) = 𝐸𝐼 )
d) Shear (𝑉(𝑥) = 𝐸𝐼 )
e) Loading 𝑤(𝑥) = −𝐸𝐼

The script file should plot each of the above functions on separate figures from 𝑥 = 0 to 𝑥 = 𝐿
using the following parameters:

𝐿 (cm) 𝐸 (kN/cm2) 𝐼 (cm4) 𝑤 (kN/cm)


600 50,000 30,000 2.5

Notes:

 Create the variables for length, modulus of elasticity, moment of inertia and load.
 Manually take the first to fourth derivatives of the function and then create the 5
anonymous functions for Displacement, Slope, Moment, Shear and Loading.

2
MECH 2150 Mechanical Engineering Modelling and Numerical Methods Fall 2025

 To plot on separate figures, open a new figure before each plot using figure(1),
figure(2), figure(3), etc. commands on the line before the plot command.
 Include the clear and clc commands as the first two lines of your code.
 Include comments throughout the script file.
 Include axes labels and a title for each plot.

3.
The function can be evaluated using the following infinite series:

1
= 1+𝑥+𝑥 +𝑥 +⋯
1−𝑥
Create a function m-file called Lab1Q3.m that evaluates the function to a certain error
tolerance  s (i.e, continues adding terms one at a time until the approximate percent relative
error  a   s ).

The input variables to the function should be x ,  s and the maximum number of terms
maxterms. In case the solution will not converge, it is always a good idea to specify a
maximum number of iterations or terms such that the code will terminate when either
 a   s or the number of terms reaches the maxterms value.

The output variables should be the result of the function (funcex), the approximate error after
convergence is reached (  a ), and the number of terms required for the solution to converge
(terms). The first line of the function should therefore be as follows:

function [funcex,ea,terms]=Lab1Q3(x,es,maxterms)

Test this function for x  0.5,  s  1 x 10-5 % and maxterms = 100 using the following
command in Command Window:

[funcex, ea, terms]=Lab1Q3(0.5, 1e-5,100)

The solution should be:

funcex = 2.0000
ea = 5.9605e-6
terms = 24

Submission Requirements for Computer Lab 1: Submit your three m-files (Lab1Q1.m,
Lab1Q2.m and Lab1Q3.m)

You might also like