introduction to matlab 7 matlab programming for engineer hassan migdadi spring 2013

16
Introduction to MATLAB 7 Introduction to MATLAB 7 MATLAB Programming for Engineer MATLAB Programming for Engineer Hassan Migdadi Spring 2013 Hassan Migdadi Spring 2013

Upload: teresa-price

Post on 14-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

Introduction to MATLAB 7Introduction to MATLAB 7Introduction to MATLAB 7Introduction to MATLAB 7

MATLAB Programming for Engineer MATLAB Programming for Engineer

Hassan Migdadi Spring 2013Hassan Migdadi Spring 2013

Page 2: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

MATLAB Properties I• MATLAB is a very powerful

mathematical computational tool.• MATLAB comes from MATrix LABoratory• MATLAB provides extensive capabilities

for generating graphs• MATLAB is applicable to a broad range

of engineering problems

Page 3: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

MATLAB Properties II• MATLAB supports an interactive and a

programming environment• Think of the interactive environment as

a “super calculator” with graphics• Think of the programming environment

as tool for writing programs to perform complex calculations

Page 4: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

MATLAB Properties III• Where does MATLAB fit?

– It is usually easier to write programs in MATLAB as compared to C or Fortran

– C or Fortran programs will usually run faster than MATLAB programs

– But, MATLAB is optimized for matrix manipulations and programs formalized in this way will run faster than similar programs in C or Fortran

Page 5: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

Course of Study• MATLAB Environment Chp. 2• Built-In MATLAB Functions Chp. 3• Manipulating MATLAB Matrices Chp. 4• Plotting Chp. 5• User Defined Functions Chp. 6• User Controlled Input and Output Chp. 7• Logical Functions and Control Structures Chp. 8• Matrix Algebra Chp. 9• Symbolic Mathematics Chp. 11• Polynomials/Curve Fitting Chp. 12

Page 6: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

Assignments• The percent symbol % is used to define

a comment, use this following the MATLAB prompt to add your name and assignment number to your work

>>% Hassan Migdadi>>% Assignment 1

Page 7: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

Assignments

• Many assignment require you to print the Edit window, the Command Window and the Figure window(s). Just print them all and staple them together when you turn them in. Remember to clear the command window before your final run to start with a clean slate.

Page 8: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

More on Assignments• The first few assignments can

easily be done with paper and pencil and a calculator but you need to do them using MATLAB. Only outputs from MATLAB will be accepted.

Page 9: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

An Engineering Problem-Solving Methodology

• Step 1: State the problem clearly.• Step 2: Describe the inputs and

outputs.• Step 3: Work the problem by hand with

a set of simple data.• Step 4: Develop the MATLAB solution• Step 5: Test the solution with real data

Page 10: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

Getting StartedExample 1

d = ½ * g * t^2

where “d” is the distance a body falls freely in a gravitation field during t Seconds and “g” has an approximate value of 9.81 m/s2

Example 2

x(t) = exp (-alpha * t ) * cos ( omega * t )

Page 11: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

Example I• Using MATLAB we want to create a

table of values of time and distance for time increments between 0 and 10 seconds.

Page 12: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

Example II• Using MATLAB we’ll do an analysis

of a suspension system and plot position versus time as the system responds to an initial displacement.

Page 13: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

Continuing with today’s Discussion

• MATLAB Help and Demos• Introduce various MATLAB windows• Use the Command Window• Use the Edit Window• View results in the Command

Window and the Graphics Window

Page 14: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

Discussion Next Class- MATLAB Environment

• MATLAB variables• Working with Matrices• Scalar Operations• Precedence of Arithmetic Operators• Array Operations• Saving your Work

– Saving Variables– M-files (Writing and saving programs)

Page 15: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

And now . . .

OFF TO MATLAB…

Learn by doing . . .

Page 16: Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013

Referances • www.engr.uaa.alaska.edu/soe/cour

ses/engr161/