Presentation is loading. Please wait.

Presentation is loading. Please wait.

Matlab Workshop Getting Started.

Similar presentations


Presentation on theme: "Matlab Workshop Getting Started."— Presentation transcript:

1 Matlab Workshop Getting Started

2

3

4

5

6

7

8 Command Window Editor

9 Matlab As A Really Fancy Calculator
In the command window enter the following: 1+2

10 Matlab As A Really Fancy Calculator
In the command window enter the following: 1+2

11 Addition In the command window enter the following: 1+2+3

12 Subtraction In the command window enter the following: 5-3

13 Multiplication In the command window enter the following: 4*6

14 Division In the command window enter the following: 15/3

15 Exponents In the command window enter the following: 2^3

16 Brackets In the command window enter the following: Now try: 1+2*3
(1+2)*3 Evaluated first Evaluated first

17 Matrices In the command window enter the following: [1 2; 3 4]

18 Matrix Multiplication
In the command window enter the following: [1 2; 3 4]*[2 1; 3 4]

19 Pointwise Multiplication
In the command window enter the following: [1 2; 3 4].*[2 1; 3 4] “Point-wise multiplication”

20 Matrix Division In the command window enter the following:
[1 2; 3 4]/[2 1; 3 4]

21 Point-wise Matrix Division
In the command window enter the following: [3 8; 15 24]./[3 4; 5 6] “Point-wise division”

22 Trigonometry In the command window enter the following: sin(1.57)
cos(1.047)

23 Trigonometry In the command window enter the following: tan(0.7854)

24 Trigonometry In the command window enter the following: asin(0.4794)
acos(0.8776) atan(0.2553)

25 Variable Assignment In the command window enter the following:
This creates a variable called “a” and assigns it a value of 2.

26 Variable Assignment Q: Why did it say a = 2 after I hit enter? A: Because if you don’t end the line with “;” then Matlab prints out the result of your operation.

27 Suppressing Output b = 3;

28 Suppressing Output b = 3; No extra output!

29 Let’s make another variable
c = 5;

30 Now We Can Do Math With Our Variables
In the command window enter the following: a+b b*c a+b*c

31 Variable Types a = 2; b = 2.75; Integer Rational Number

32 Variable Types c = ‘z’; d = ‘hello’; Character String

33 Variable Types e = [2 3]; f = {3,2}; Array Cell Array

34 Variable Types h = [2 1; 3 4]; Matrix

35 Variable Types g.Name = 'Me'; g.Age = 28; Structure Array

36 Indexing Each variable type has a particular indexing syntax:
h(2,1) % Matrices are indexed by row and then column a(1) % Integers are special cases of matrices b(1) % So are rational numbers c(1) % So are characters d(2) % So are strings e(2) % So are arrays f{2} % Cells are indexed using curly braces g.Name % Struct arrays are indexed using the "." notation

37 Indexing Each variable type has a particular indexing syntax:
h(2,1) % Matrices are indexed by row and then column a(1) % Integers are special cases of matrices b(1) % So are rational numbers c(1) % So are characters d(2) % So are strings e(2) % So are arrays f{2} % Cells are indexed using curly braces g.Name % Struct arrays are indexed using the "." notation

38 Math With Variables a+b a-b a*b a/b sin(a) cos(a) tan(a) log(a) exp(a) h*h h.*h h/h


Download ppt "Matlab Workshop Getting Started."

Similar presentations


Ads by Google