Professional Documents
Culture Documents
2x + 3y − z = 12 3x − 9z = 33 2x + 5y + 2z = −38
3x − 2y + 2z = −5 7x − 4y − z = 15 3x − 2y + 4z = 17
x + 4y − 3z = 7 4x + 6y + 5z = −6 −6x + y − 7z = −12
Finding Solutions using MATLAB
Where: a, b, c, d = coefficients
𝑛 𝑛−1 𝑛−2 𝑛−𝑛 z = constant
a𝑥 + b𝑥 + c𝑥 … d𝑥 =z
x = unknown variable
2𝑥 2 + 3x − 9 = 0 𝑥 2 − 18x + 81 = 0 𝑥 2 − 6x − 16 = 0
Plotting graphs in MATLAB
1. Create a vector for the independent variable.
2. Assign a function.
3. Plot the function using “plot(x,y)” command.
Using MATLAB:
𝑥 = [0: 1: 10]
𝑓 𝑥 = sin(𝑥)
𝑝𝑙𝑜𝑡 (𝑥, 𝑦)
Plotting graphs in MATLAB
Sample Exercise:
y= 𝑐𝑜𝑠(𝑥)
Writing a function on MATLAB
1. Prepare/solve for the mathematical equation.
2. Click on New Script at the command window.
3. Write the code function [output var.] = function_name(input var.)
4. Enter, write the equation with the respective output and input variables, with semicolon at the end.
5. Enter, end.
6. Save the function as a file using the current folder location.
7. Work with the function and find the solution.
A ball is dropped from a height of 60 meters above Time of fall gravity x, y and z
ground. How long does it take to hit the ground?
t ---- x,y,z
1 2 time ---- ---
ℎ = 𝑔𝑡
2
Note: Don’t forget to create and use assigned Function folder in the MATLAB folder
as a current folder. For the square root command, use sqrt (X).
Differentiation and Integration in MATLAB
Differentiation Integration
1. Assign a variable using 1. Assign a variable
“syms” command using “syms”
2. Write the equation of command
the function of the 2. Write the equation
assigned command of the function of
3. Write and assign the the assigned
derivative of the command
function using “diff” 3. Write and assign the
command. integral of the
function using “int”
command.
Differentiation and Integration in MATLAB
Sample Problem
Plot the curve of the displacement, velocity
and acceleration.
Integration in MATLAB
Sample Problem
A force 𝐹 in Newtons is applied to move an object along a straight line from 𝑥 = 2 meters to 𝑥 = 5
meters. The force at any point x meters is given by 𝐹(𝑥) = 2𝑥 + 1 Newtons. Find the work done in
moving the object from 𝑥 = 2 𝑡𝑜 𝑥 = 5.
𝐹(𝑥) = 2𝑥 + 1
0 1 2 3 4 5
Integration in MATLAB
Sample Problem
A force 𝐹 in Newtons is applied to move an object along a straight line from 𝑥 = 2 meters to 𝑥 = 5
meters. The force at any point x meters is given by 𝐹(𝑥) = 2𝑥 + 1 Newtons. Find the work done in
moving the object from 𝑥 = 2 𝑡𝑜 𝑥 = 5.
𝐹(𝑥) = 2𝑥 + 1 𝑏
𝑊 = න 𝐹 𝑥 𝑑𝑥
𝑎
𝑎=2 𝑏=5
5
𝑊 = න 2𝑥 + 1 𝑑𝑥
2
0 1 2 3 4 5 5
𝑊 = 𝑥2 + 𝑥 2
𝑊 = 24 𝐽𝑜𝑢𝑙𝑒𝑠
Integration in MATLAB
Sample Problem
A force 𝐹 in Newtons is
applied to move an object along
a straight line from 𝑥 = 2
meters to 𝑥 = 5 meters. The
force at any point x meters is
given by 𝐹(𝑥) = 2𝑥 +
1 Newtons. Find the work done
in moving the object from 𝑥 =
2 𝑡𝑜 𝑥 = 5.
Final Exam (Activity)
Solve the following using MATLAB.
1. A particle is moving along a straight line, and the force acting on it is given by 𝐹(𝑥) = 3𝑥^2 for 1 ≤ 𝑥 ≤ 2.
Find the work done in moving the particle from 𝑥 = 1 to 𝑥 = 2.
2. The rate at which rain is falling into a container is given by the function 𝑅′(𝑡) = 0.2𝑡 − 0.1, where 𝑅(𝑡)
represents the total amount of rainfall accumulated up to time t in hours. Find the total amount of rainfall
accumulated after 4 hours.
3. The rate at which a substance is cooling is given by the function 𝑇′(𝑡) = −0.02𝑡 + 0.3, where 𝑇(𝑡)
represents the temperature of the substance at time 𝑡 in minutes. Find the total change in temperature
after 10 minutes.
4. A tank initially contains 500 liters of water. The rate at which water is draining from the tank is given by
𝑉′(𝑡) = −2𝑡 liters per minute, where 𝑉(𝑡) is the volume of water in the tank at time 𝑡 in minutes. Find the
volume of water in the tank after 3 minutes.