Professional Documents
Culture Documents
ENGINEERING
ENG1060
1. Introduction to ENG1060
2. MATLAB basics
3. Matrices
4. Plotting
5. Good programming practices
6. Functions
7. Input and output
8. IF statements
9. Loops, loops, loops…
10. Debugging MATLAB programs
11. Advanced functions
12. Data types and MATLAB limitations
2
ENG1060
LABS
3
ENG1060
Students
– Are not preparing for the labs
– Hard coding and not creating variables
– Still don't know how to use the min/max functions
(Preaching to the wrong audience?)
– Are overall better than previous semesters
4
ENG1060
Examples:
A = 'abcdef'
B = '1a2b3c'
C = '%^&*#^&%$'
5
ENG1060
6
ENG1060
7
ENG1060
8
ENG1060
9
ENG1060
Conversion specifiers tell fprintf where and how variable values should be
printed
%printing information
fprintf('The length of the hypotenuse is given by %f', hyp_length)
10
ENG1060
EXAMPLE 1
Plot the given time and speed vectors. Determine the maximum point and mark
it on the same plot.
t = 70:10:150;
s = -(t-100)2 + 2500;
11
ENG1060
EXAMPLE 2
A torus is a shaped like a doughnut. If its inner radius is ‘a’ and its outer radius is
‘b’, its volume and surface area are given by:
1
𝑉 = 𝜋 2 𝑎 + 𝑏 𝑏 − 𝑎 2; A = 𝜋 2 𝑏 2 − 𝑎2 ;
4
EXAMPLE 2
A torus is a shaped like a doughnut. If its inner radius is ‘a’ and its outer radius is
‘b’, its volume and surface area are given by:
1
𝑉 = 𝜋 2 𝑎 + 𝑏 𝑏 − 𝑎 2; A = 𝜋 2 𝑏 2 − 𝑎2 ;
4
13
ENG1060
DATA OVERLOAD
14
ENG1060
15
ENG1060
16
ENG1060
EXAMPLE 3
17
ENG1060
EXAMPLE 3
Do the same thing but now with the "long_jump_records2.txt" file which has a
different structure using fgetl…
… and importdata
18
ENG1060
1. Introduction to ENG1060
2. MATLAB basics
3. Matrices
4. Plotting
5. Good programming practices
6. Functions
7. Input and output
8. IF statements
9. Loops, loops, loops…
10. Debugging MATLAB programs
11. Advanced functions
12. Data types and MATLAB limitations
19