Part II - Lecture 1
description
Transcript of Part II - Lecture 1
-
GENG1003 Introduction to Procedural Programming
MATLAB
-
What is MATLAB?
MATLAB is one of a number of commercially available, sophisticated mathematical computation tools
Good for:
Numerical calculations
Especially involving matrices
Graphics
MATLAB stands for Matrix Laboratory
Easy to use
Versatile
Built in programming language
Not a general purpose language like C++ or Java
-
How is MATLAB used in Industry?
Widespread, especially in the signal processing field
Tool of choice in Academia for most engineering fields
Some examples.
-
Electrical Engineering
These images simulate the visual system used in a housefly
brain to detect collisions. The techniques developed are being
used in autonomous robot systems that depend upon vision
for navigation. The data was processed using MATLAB.
-
Biomedical Engineering
These images were created from MRI scan data using MATLAB.
The actual data set is included with the standard MATLAB
installation, allowing you experiment with manipulating the data
yourself.
-
Fluid Dynamics
Results from a finite element analysis code were post processed
using MATLAB to create this image.
-
Problem Solving in Engineering and Science
1. State the Problem
2. Describe the input and output
3. Develop an algorithm
4. Solve the problem
5. Test the solution
-
1. State the Problem
If you dont have a clear understanding of the problem, its unlikely that youll be able to solve it
Drawing a picture often helps you understand the system better
-
2. Describe the Input and Output
Be careful to include units
Identify constants
Label your sketch
Group information into tables
-
3. Develop an Algorithm
Identify any equations relating the knowns and unknowns
Work through a simplified version of the problem by hand or with a calculator
Developing a flow chart is often useful for complicated problems
-
4. Solve the problem
Create a MATLAB solution
Be generous with comments, so that others can follow your work
-
5. Test the Solution
Compare to the hand solution
Do your answers make sense physically?
Is your answer really what was asked for?
Graphs are often useful ways to check your calculations for reasonableness
-
Example
E = mc2
The sun is fueled by the conversion of matter to energy
How much matter does the sun consume every day?
-
State the Problem
Find the amount of matter necessary to produce the amount of energy radiated by the sun everyday
-
Describe the Input and Output
Input
Rate of energy radiation
E = 385*1024 Joules/second
Speed of light
c = 3.0*108 meters/second
Output
Mass in kilograms
-
Develop an Algorithm Hand Example
The energy radiated in one day is:
Rearrange E=mc2 and solve for m
m=E/c2
Jdayday
hours
hour
J 3124 1033.31*24sec
3600sec
10385 =
( )2831
sec/100.3
1033.3
m
Jm
=
22
14
sec/107.3
m
J=
-
But the units are still wrong.
1 J = 1 kg m2/sec2
kgm
mkg 1422
2214 107.3
sec/
sec/ 107.3 ==
14
2 23.7 10
/ sec
J
m
-
Well start learning the details of how to use MATLAB in the next lecture.
However, you can see from the following demonstration just how easy it is to use the command window
Develop a MATLAB Solution to Solve the Problem
-
Develop a MATLAB Solution to Solve the Problem
-
Test your Solution
Matches the hand solution
Is it reasonable?
Consider
Mass of the sun = 2*1030 kg
How long would it take to consume all that mass?
-
Test your Solution
Only 10% is available for hydrogen fusion in its core.
So, effectively, the available mass is 2*1029 kg
Also, hydrogen fusion only converts 0.68% of the mass into energy.
Therefore, the mass effectively used is only 2*1029 * 0.68 / 100 =1.4*1027 kg
-
time = (mass of the sun)/(rate of consumption)
Thats 10.3 billion years!!
Yes this is a reasonable result. The sun is believed to be 4-
5 billion years old and should have another 5 billion years
ahead of it, until it burns all its hydrogen and starts burning
helium. It will become a red giant, swallow Mercury, Venus,
Earth and Mars, and then collapse and become a cold, white
dwarf star.
Test your Solution
time = 1.4*1027 kg * year = 1.03*1010 years
3.7*1014 kg/day 365 day
-
Use the Help
-
Use the Help
-
Use MATLABs Help