FINAL MERGE EEE515 (Goodluck) - Compressed
FINAL MERGE EEE515 (Goodluck) - Compressed
The Use of
Engineering
PROF.
Packages.
ADEMOLA
ABDULKAREEM MATALB
1
INTRODUCTION
• In the digital age, where complexity and
interconnection reign, efficient management and
communication of engineering information are
crucial. Engineering, driving innovation and
progress, shapes our world. Engineering packages
act as the essential link between visionary ideas and
practical solutions. In this course, we'll explore
engineering packages, with a focus on
MATLAB/SIMULINK, the dynamic duo of
engineering and simulation.
3
Key Components of
Engineering Packages
1. Design Drawings: Detailed schematics, blueprints, and diagrams
illustrating the physical layout and dimensions of components, systems, or
structures.
7
• MATLAB, stands for "Matrix Laboratory," is not just a
software program. It is a dynamic, interpreted, environment for
matrix/vector analysis.
8
•Engineering: MATLAB is a go-to tool for engineers, enabling them to solve complex
mathematical problems, simulate systems, and analyze data in various engineering
disciplines such as mechanical, electrical, and civil engineering.
•Data Science: In the age of big data, MATLAB is a valuable asset for data scientists,
Applications offering powerful statistical and machine learning capabilities for extracting insights
from large datasets.
of MATLAB •Academia: MATLAB is a staple in academia, where it aids in teaching and research
across disciplines, helping students and researchers bring their ideas to life.
•Image and Signal Processing: MATLAB excels in processing and analyzing images
and signals, making it crucial in fields like computer vision, remote sensing, and
telecommunications.
•Aerospace and Defense: Engineers in these industries rely on MATLAB for tasks
such as designing control systems, analyzing flight data, and simulating complex
systems…to design control systems, analyze flight data, and simulate 9
• Interactive Environment: MATLAB provides an interactive environment where you can
perform computations, visualize results, and experiment with algorithms in real-time. Its
command window allows for rapid prototyping and quick testing of ideas.
• Rich Functionality: MATLAB boasts a vast library of built-in functions and toolboxes
covering everything from linear algebra and optimization to image processing and machine
learning. These functions save time and simplify complex tasks.
Key Features operations, making it ideal for applications involving large datasets and systems of
equations.
of MATLAB • Graphics and Visualization: MATLAB's plotting and visualization tools are renowned for
creating stunning graphs, charts, and animations, making it easy to present and understand
data.
• Simulink Integration: Simulink, a companion tool to MATLAB, extends its capabilities into
the realm of dynamic systems modeling and simulation. This integration is invaluable for
control system design, mechatronics, and more 10
MATLAB in Power Systems
Power System Simulation: MATLAB is extensively used for simulating
power systems, enabling engineers to model and analyze electrical grids'
behavior under various operating conditions.
Load Flow Analysis: Engineers employ MATLAB to conduct load flow
studies, ensuring that power generation, transmission, and distribution
are optimized, reliable, and compliant with standards.
Fault Analysis: In the event of faults or disturbances, MATLAB helps in
fault analysis, enabling quick detection and efficient response to minimize
downtime and ensure grid stability.
Renewable Energy Integration: As the world embraces renewable
energy sources, MATLAB assists in integrating solar, wind, and other
renewables into the grid, optimizing energy generation and distribution.
11
MATLAB in Power Systems
Control System Design: MATLAB supports the design of control
systems for power generation and distribution, enhancing grid stability
and efficiency.
Energy Storage Optimization: With the growing importance of energy
storage systems, MATLAB aids in optimizing the use of batteries and
other storage technologies to balance supply and demand.
Microgrid Design: For the development of microgrids, especially in
remote or off-grid areas, MATLAB is instrumental in designing and testing
resilient and efficient solutions.
Grid Modernization: MATLAB contributes to the modernization of
electrical grids, enabling the integration of smart grid technologies for
real-time monitoring and control
12
13
Let’s examine basic commands typed at the
command prompt
• Arrays
• Equations
• Polynomials
• Plotting
• Systems of equations
M-files
• Decision-making
• Loops
Polynomial fitting
14
Let’s examine basic commands typed at the command
prompt
• Arrays MATLAB…
• Equations
• Polynomials
• Plotting
• Systems of equations
M-files
• Decision-making
• Loops
Polynomial fitting
15
Arrays
• Arrays
• Equations
• Polynomials
• Plotting
• Systems of equations
M-files
• Decision-making
• Loops
Polynomial fitting
20
Equations
Let’s define an equation. As an example, consider the
volume, V, of a circular cylinder.
Show the students last week’s problem
V πr 2h
r
y ax bx c
b b2 4ac
2
x1,2
2a
MATLAB has a function “roots” that can be used to find the roots of n th-order polynomials.
Consider the example:
y 1x 2 15x 50
15 152 4 1 50 15 5
x1,2
2 1 2 1
x1 5 x 2 10
Let’s complete the same example using MATLAB.
Let’s examine basic commands typed
at the command prompt
• Arrays
• Equations
• Polynomials
• Plotting
• Systems of equations
M-files
• Decision-making
• Loops
Polynomial fitting
24
Let’s examine basic commands typed at the
command prompt
• Arrays
• Equations
• Polynomials
• Plotting
• Systems of equations
M-files
• Decision-making
• Loops
Polynomial fitting
25
Systems of Equations
Can use MATLAB to solve systems of linear equations.
2 9 x1 5
A x b
3 - 4 x 2 7
r
2π r 3
V
h 3
πr 2 h
C 3002π rh 400 2π r 2
29
The aorta is the largest artery in the body, originating from the left ventricle of the heart
and bringing oxygenated blood to all parts of the body in the systemic circulation. The
aorta extends down to the abdomen, where it branches off into two smaller arteries
30
M-File
The blood pressure in the aorta during systole (the period
following the
. closure of the heart’s aortic valve) can be
described using:
y t e - 8t
sin 9.7t
2
http://en.wikipedia.org/wiki/Aorta
Hold on is used to add
an additional plot to the
previous plot 1.2
5 steps
1
per
cycle
0.8
0.6
100 steps
y(t)
0.4
per cycle
-0.2
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
time (s)
Let’s examine basic commands typed at the
command prompt
• Arrays
• Equations
• Polynomials
• Plotting
• Systems of equations
M-files
• Decision-making
• Loops
Polynomial fitting
33
Decision-Making
The usefulness of computer programs is increased
by using decision-making functions. This enables operator meaning
operations to be completed that depend on the < Less than
results of calculations.
<= Less than or
equal to
The relational operators make comparisons between
arrays. > Greater than
>= Greater than or
The result of using relational operators is 1 if true equal to
and 0 if false.
== Equal to
56 False = 0
~= Not equal to
5 5 True = 1
You can compare arrays in element-by-element fashion. Let’s
5 ~ 5 False = 0
consider some examples…
x = [6 3 9] y = [14 2 9]
x = [6 3 9] y = [14 2 9]
9<9, false = 0
6<14, true = 1
x = [6 3 9] y = [14 2 9]
x = [6 3 9] y = [14 2 9]
9~=9, false = 0
6~=14, true = 1
Can also compare arrays to a scalar.
x = [6 3 9] 8
x = [6 3 9] 8
9>8, true = 1
6>8, false = 0
Decision-Making
The logical operators also make comparisons between arrays. The result of using logical operators
is again 1 if true and 0 if false.
operator name definition
~ NOT “~A” returns an array with the same dimensions as
“A”; the new array has ones where “A” is zero and
zeros where “A” is nonzero
~x(3) = ~9 = 0
~x(1) = ~0 = 1
“~A”
returns an array with the same
dimensions as “A”; the new array has ones
where “A” is zero and zeros where “A” is
nonzero
z = ~x > y = ~[0 3 9] > [14 -2 9]
~x = ~[0 3 9] = [1 0 0]
[0 3 9] > [14 -2 9]
[0 1 0]
~[0 1 0]
z=0&3=0
z=2&3=1
Consider a projectile that is launched with a speed v0 at an angle A (relative to the
horizontal). Its height, h, and velocity, v, depend on the time since launch (at t = 0).
v(t)
v0
h(t)
A
v <= 16 m/s
v0
h>=6m
A
Solve for v and h as a function of time. Use relational and logical operators to find
times when height and velocity conditions are both true.
Write a program (m-file) to complete this task. Plot v and h versus t to check the
results.
Decision-Making
Find the times (between t = 0 and thit) when the height is no less than 6 m and the speed is simultaneously
no greater than 16 m/s.
10
h(t)
4
0
0 0.5 1 1.5 2 2.5
20
19
t1 = 0.8649 s t2 = 1.7560 s
18
For the specified conditions,
v(t)
17
the velocity limits the range.
16
15
0 0.5 1 1.5 2 2.5
time (s)
Decision-Making
The conditional statements if, else, and elseif also enable decision-making in programs.
if logical expression 1
if statements may if logical expression 2
also be nested. statements
end
end
Decision-Making
When more than one action can occur as the result of a decision, use else and elseif statements along
with the if statement.
if logical expression
The basic structure of the else statement is: statements 1
else
statements 2
end
Consider the case that y = sqrt(x) for x >= 0 and that y = ex-1 for x < 0.
if x >= 0
y = sqrt(x);
else
y = exp(x) – 1;
end
Decision-making
The elseif statement enables an additional decision to be made with an if statement.
if logical expression 1
The basic structure of the elseif statement is: statements 1
elseif logical expression 2
statements 2
else
Consider the case that y = ln(x) for x > 10,
statements 3
y = sqrt(x) for 0 <= x <= 10, and y = ex-1
end
for x < 0.
if x > 10
If not true, then
y lnx ,
y = log(x);
x 10 elseif x >= 0
x is <= 10.
y x, 0 x 10 y = sqrt(x);
x0 else If not true, then
y e 1,
x
y = exp(x) – 1; x is < 0.
end
Decision-Making
Consider the previous example and write an m-file to determine the result based on the selected x
value.
0 x 10 y x
x0 y ex 1
MATLAB…
Let’s examine basic commands typed at the command prompt
• Arrays
• Equations
• Polynomials
• Plotting
• Systems of equations
M-files
• Decision-making
• Loops
Polynomial fitting
51
Loops
A loop is a structure used to repeat a calculation (or group of statements) a number of times. The
for loop is used when the number of repetitions is known beforehand. The while loop is used when
the loop continues until a specified condition is satisfied.
for counter = m:s:n “m” is the starting value of the loop counter
statements “s” is the step size of the counter
end “n” is the final value of the loop counter
Example: Write an m-file to compute the sum of the first 15 terms of the series 5k 2 – 2k, where k = 1,
2, 3…
55
INTRODUCTION
Simulink is a graphical, drag-and-drop environment for building
simple and complex signal and system dynamic simulations.
It allows users to concentrate on the structure of the problem,
rather than having to worry (too much) about a programming
language.
The parameters of each signal and system block is configured by
the user (right-click on the block)
Signals and systems are simulated over a particular time.
Starting and Running Simulink
Type the following at the Matlab command prompt “simulink”
Click the blank model to create a new workspace
The Simulink library should be seen on the library browser click
on it. The library will appear and drag and drop objects from the
library onto the workspace.
Selecting run will run the dynamic simulation. Click on the blocks
to view the data or alter the run-time parameters
Signals and Systems in Simulink
Two main sets of libraries for building simple simulations in
Simulink
Signals Sources and Sinks
Systems Continuous and Discrete
◦ Sources Used to generate input signals
◦ Sinks Used to display results/signals
◦ Continuous To represent continuous systems
◦ Discrete To represent discrete systems
◦ Math Some mathematical functions
Basic Example 1
Copy sine wave source and scope onto a new Simulink workspace and
connect.
Set sine wave parameters modify to 2 rad/sec by double clicking on it
Run the simulation
Simulation - Start
Open the scope and leave it open while you change
parameters (sin or simulation parameters) and
re-run
Basic Example 2
Simulate the following system
xሷ + 2xሶ + x = sin(2t)
x 0 = x 0 ሶ= 0
Solution
x1 = x
x2 = xሶ
xሶ 1 = x2
xሶ 2 = sin 2t − 2x2 − x1
RESULT
NOTE
A system is represented by a block diagram
You need to know the library that contains the block that you need
click on the library name and you will see a list of blocks in that library
click on the block that you want and drag it to the work file
63
1.0 INTRODUCTION
(iii) Flowcharting
(iv) Programming
(ii) Algorithm
where e = √𝑏 2 − 4𝑎𝑐
Step 1: Set I = 1
Step 2: Read a, b, c.
Step 3: Check is a = 0? If yes, print the wrong data and go to
step 9, otherwise go to the next step
Step 9: Increase I by 1.
Step 10: Check is I ≤ 10? If yes, go to step 2, otherwise go to
the next step
Start
A terminating symbol, including start or end of the
Or
flow chart. This symbol is also used as a connector
End
Assignment 1: Draw a flow chart to find the real roots of the
equation 𝑎𝑥 2 + 𝑏𝑥 + 𝑐 = 0, 𝑎, 𝑏, 𝑐, real, for ten
sets of values of a, b, c. using the method
Embedded Systems
Embedded systems are computer systems consisting of hardware
and software components and are designed to do a specific task.
Some examples of embedded systems are washing machines,
printers, automobiles, cameras, industrial machines, etc. With the
push of one button, MATLAB allows us to generate code and run it
on hardware.
Wireless Communications
Wireless communication is a broad term used for connecting two
devices using a wireless signal. Teams in wireless Engineering use
MATLAB to reduce development time, eliminate design problems
early, and streamline testing and verification.
Internet of Things
Internet of Things is the network of devices, vehicles and home
appliances and others embedded with electronics, software,
sensors, actuators, and connectivity which enables the exchange of
data. uses of MATLAB help in the design, prototype, and
deployment of IOT applications such as predictive maintenance,
operations optimization, supervisory control etc.
Robotics
Robotics is an interdisciplinary field of science and engineering. It
involves mechanical engineering, electronic engineering, and
computer science to name a few to create robots or human-like
machines. Robotics researchers and engineers use MATLAB to
design and tune algorithms, model real-world systems, and
automatically generate code – all from one software environment.
Data Analytics
Data Analytics is the process of studying data in order to gain
insights. It is mostly done with the help of other software and tools.
Engineering and IT people are using MATLAB to build the Big Data
Analytics Systems.
Commands
2
Matlab
SIMULINK
Simulink is a simulation and model-based design
environment for dynamic and embedded systems, which are
integrated with MATLAB.
3
Simulink is a visual programming interface designed to make modelling systems intuitive. It offers a
way to solve equations numerically using a graphical user interface, rather than requiring code. Models
contain blocks, signals and annotation on a background:.
•Blocks are mathematical functions, they can have varying numbers of inputs and outputs.
•Signals are lines connecting blocks, transferring values between them. Signals are different data
types, for example numbers, vectors or matrices. Signals can be labelled.
•Annotations of text or images can be added to the model, and while not used in the calculations they
can make it easier for others to understand design decisions in the model.
4
Starting and
Running Simulink
1. Type the following at the Matlab command
prompt “simulink”
10
NOTE
• A system is represented by a block diagram
• You select the block from a library of blocks
• You need to know the library that contains the block that you need
• click on the library name and you will see a list of blocks in that library
• click on the block that you want and drag it to the work file
• click on the block to select its parameters
• Connect it to other blocks
Thank you for Listening
DR ADEMOLA ABDULKAREEM
12