You are on page 1of 36

LECTURE 1

INTRODUCTION AND MATLAB


COMPUTING FOR ENGINEERS
ENVIRONMENT
ENGN130

LECTURE 1: MATLAB INTRODUCTION


AND BASIC CALCULATION

Dr. Van Vinh Nguyen


Email: van-vinh.nguyen@learning.sibt.nsw.edu.au
nguyenvanvinhutc@yahoo.com
Mobile: +61.435.768.570

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 1/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

1. Unit introduction
 Sydney Institute of Business and Technology (SIBT)
 Unit number and name: ENGN130 – Introduction and MATLAB Environment
 Summary: ENGN130, Computing for Engineers is an introductory programming
course that uses MATLAB and C++ to illustrate general concepts in programming.
This unit enable students to have fundamental knowledge of programming and
MATLAB and C++. This unit is aimed for engineering students. ENGN130
demonstrates how complex engineering and mathematical problems can be solved
using lines in MATLAB and traditional programming languages like C++.
 Credit points: 3
 Unit level: Undergraduate Unit

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 2/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

1. Unit introduction
 Learning outcomes: on successful completion of this unit, students should be able
to:
 Gain an understanding of general concepts of programming and obtain a solid foundation
in the use of different programming languages.
 Evaluate the applicability of different languages in computer programming.
 Solve simple mathematical and engineering problems using an algorithmic approach.
 Apply standard programming practices to document, debug and test their programs.

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 3/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

1. Unit introduction
 Mode of delivery:

 Assessment items and weighting

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 4/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

1. Unit introduction
 Assessment plan:

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 5/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

1. Unit introduction
 Essential readings
 Lecture notes
 Hahn, B & Valentine, DT 2016, Essential MATLAB for engineers and scientists, 6th edn,
Elsevier Science, Saint Louis.
 Deitel, PJ & Deitel, HM 2013, C++: how to program, 7th edittion, Prentice Hall, Boston.

 Online learning requirements


 Students are expected to consult View side at least twice a week, as all announcements
will be made via View side and teaching material will be regularly updated and posted
online.
https://www.tutorialspoint.com/matlab/matlab_plotting.htm

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 6/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

2. Topics
 MATLAB introduction and applications
 MATLAB environment
 Basic commands
 Arithmetic in MATLAB
 Operators
 Variables

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 7/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

3. Power of computers
 Applications can be used effectively by computers.
 How to develop these applications?

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 8/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

4. Programing languages
 Many programing languages which support people to develop software and
applications.

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 9/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

5. Matlab introduction
 Matrix Laboratory
 A programming package specifically designed for quick and easy scientific
calculations and I/O.
 It has literally hundreds of built-in functions for a wide variety of computations
 Many toolboxes designed for specific research disciplines: statistics, optimization,
solution of partial differential equations, data analysis.

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 10/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

6. Matlab applications
 For Mathematic:

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 11/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

6. Matlab applications
 For structural engineering:

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 12/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

6. Matlab applications
 For structural engineering:

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 13/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

6. Matlab applications
 For electrical engineering:

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 14/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

6. Matlab applications
 For data analysis:

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 15/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

6. Matlab applications
 For signal analysis:

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 16/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

7. Matlab working environment


 Main window:

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 17/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

7. Matlab working environment


 Editor window:

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 18/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

8. Basic commands
 clc: clears the screen
 home: moves the mouse back to the left of the screeen
 help: support information
 edit: opens the editor window
 demo: opens demo programs
 quit: closes the Matlab window
 exit: closes the Matlab window
 guide: opens a new GUIs (Graphic User Interfaces)
 deploytool: opens the compiling window

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 19/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

9. Arithmetic in Matlab
 General functions:

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 20/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

9. Arithmetic in Matlab
 Addition (+):
 Subtraction (-):
 Multiplication (*):
 Devision (/):
 Exponentiation (.^):
 Example 1: simple calculations

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 21/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

9. Arithmetic in Matlab
 round (x): rounds a number
 sqrt(x): returns the square-root of a number
 abs (x): returns the absolution of a number
 floor (x): rounds down a number
 ceil (x): rounds up a number
 Example 2: simple calculations

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 22/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

9. Arithmetic in Matlab
 mod (x,y): returns the redundant of the division (x/y)
 fix (x): returns the integer of a decimal number
 sign (x): returns (-1) if the number is less than 0, return (0) if the number is
equal to 0 and returns (1) if the number is greater than 0.
 Example 3:

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 23/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

9. Arithmetic in Matlab
 exp (x): returns ex with e = 2.718
 log (x): returns ln(x)
 Example 4:

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 24/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

9. Arithmetic in Matlab
 gcd (x,y): returns the maximum common divisor of x and y
 lcm (x,y): returns the minimum common multiple of x and y
 Example 5:

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 25/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

10. Trigonometric functions


 sin (x)  The value of x in radian
 cos (x)  The value of pi=3.1416

 tan (x)
 asin (x)
 acos (x)
 atan(x)

 Converting radian  degree:


30  3.1416
x  30o  x   0.524 rad
180
0.524 180
x  0.524  x   30o
3.1416

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 26/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

11. Hyperbolic functions


 sinh (x)
 cosh (x)
 tanh (x)
 asinh (x)
 acosh (x)
 atanh (x)
e x  e x
sinh( x) 
2
e  e x
x
cosh( x) 
2
e  e x
x
tanh( x)  x  x
e e
Figure: y=sinh(x) Figure: y=cosh(x)

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 27/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

12. Operators
 Relational operators:

 Logical operators:

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 28/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

12. Operators
 Using semicolon: the semicolon prevents the value of b to be displayed
 Example 6:
>> b = 3;
>> x = 2;
>> y = 3;
>> z = x + y

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 29/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

13. Variables
 Temporary variables are only available in the Command window of MATLAB,
when close the window, all of variable will be deleted.
 Note: capital letters are different from normal letters: a is not the same A

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 30/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

13. Variables
 civilengineer
 normalCapital
 longname
 Chicken45
 red_bananas
 This_Variable_Name_Is_Quite_Possibly_Too_Long_To_Be_Considered_Good_
Practice_However_It_Will_Work

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 31/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

13. Variables
 Name rules:
 Must begin with alphabet.
 May only contain letters, numbers and underscores ( _ ).
 No spaces or punctuation marks allowed
 Only the first 63 characters are significant;
 Case sensitive (e.g. the variables a and A are not the same).

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 32/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

14. Number display


 We can use numbers in decimal format (1003123 or 0.0001323) but that is not
the always best way to handle very large numbers or very small numbers.
 Scientific Notation
 The way scientists and engineers handle very large and very small numbers Calculators
use a similar notation.

 In MATLAB, 0.00123 = 1.23 x 10-3 is denoted as 1.23e-3


 We can enter 0.00123 as 1.23e-3 (no spaces)

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 33/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

14. Number display


 Number format:

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 34/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

15. Examples
 Example 7: determine the value of the below function
A  e5  40  ln 15  with e  2.718
 Example 8: determine the value of the below function
B  2 x 4  5 x 3 y  sin  3 xy 2   x 2 y with x  2, y  0.5

 Example 9: determine the value of the below function


3x3  5 x 2  6 
C with x
2 cos x 4

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 35/36


LECTURE 1
INTRODUCTION AND MATLAB
ENVIRONMENT

Dr. Van Vinh Nguyen Computing for Engineers ENGN130 36/36

You might also like