Matlab_overview - Introduction to MATLAB 1. 2. 3. 4. 5....

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction to MATLAB 1. Basic functions 2. Vectors, matrices, and arithmetic 3. Flow Constructs (Loops, If, etc) 4. Create M-files 5. Plotting
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Basic functions MATLAB as a calculator » (3+5)/7 ans = 1.1429 » x = (3+5)/7 x = 1.1429 » x x = 1.1429 + addition - subtraction / division * multiplication ^ power Sum of (3+5) divided by 7 define a variable
Background image of page 2
Basic function (continued) If you want to see how many variables you have defined so far, you can use the following command: » who Your variables are: ans x » »whos Name Size Bytes Class ans 1x1 8 double array x 1x1 8 double array Grand total is 2 elements using 16 bytes List all the variables in the current MATLAB session List all the variables with details
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Basic function (continued) Once you have defined variables: » x = -10 x = -10 » y = 5*x y = -50 » x = (3+5)/7 x = 1.1429 *Once you have defined a value for a variable, you can use it to perform algebraic operation *By default, MATLAB displays 4 decimal digit if the value is not an integer
Background image of page 4
Special Variables In MATLAB, there are some special variables: » pi ans = 3.1416 » i, j, ans = 0+1.0000i ans = 0+1.0000i Value for π Imaginary number by default unless you change them
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Format By default, the answer only displays 4 decimal places if it is not an integer If you want to change the format of the output: » format long » pi ans = 3.14159265358979 Other format for the output: format short (4 decimal places) format short e (scientific notation) format long (more than 12) format bank (2 decimal place)
Background image of page 6
Built-in functions In MATLAB, there are many standard built-in functions » z = sin (pi/4) z = 0.7071 » q = log (4) q = 1.3863 Trigonometric function: sin ( ) asin ( ) cos ( ) acos ( ) tan ( ) atan ( ) ** Angle is in radian Elementary function: sqrt ( ) exp ( ) e log ( ) log log10 ( ) log 10
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Defining a vector (Row vector) MATLAB is a tool for doing computations with Row Vectors:
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/28/2011 for the course CHE 210 taught by Professor Swinnea during the Fall '08 term at University of Texas at Austin.

Page1 / 29

Matlab_overview - Introduction to MATLAB 1. 2. 3. 4. 5....

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online