introduction to matlab
TRANSCRIPT
![Page 2: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/2.jpg)
Introduction to MATLAB
In this workshop we will cover the following
• Using Matlab as a numerical calculator• Entering row vectors and column vectors• Entering matrices• Forming matrix and vector products• Doing matrix products, sums etc• Using Matlab to solve linear equations• Matlab functions that operate on arrays• Plotting basic graphs using Matlab.
![Page 3: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/3.jpg)
Introduction to MATLAB
Resources on the ‘K:’ drive
• Now, you may find some books and notes about MATLAB for beginners and for experts on the ‘K:’ drive under the folder name “MATLAB E-Books”
![Page 4: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/4.jpg)
Introduction to MATLAB
What is MATLAB ?
MATLAB started as an interactive program for doing matrix calculations and has now grown to a high level mathematical language that can solve integrals and differential equations numerically and plot a wide variety of two and three dimensional graphs. MATLAB also contains a programming language.
![Page 5: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/5.jpg)
Introduction to MATLAB
How to get started?
Command WindowWork Space
Command History
![Page 6: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/6.jpg)
Introduction to MATLAB
Simple arithmetic with Matlab
![Page 7: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/7.jpg)
Introduction to MATLAB
Simple arithmetic with Matlab
![Page 8: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/8.jpg)
Introduction to MATLAB
Try These!
![Page 9: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/9.jpg)
Introduction to MATLAB
The order of operations
• If you are using brackets, that will save you a lot of effort!
• However, the operators have precedence!1. “( )” brackets2. “^” Power3. “* /” Multiplication and division4. “+ -” Addition and subtraction
![Page 10: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/10.jpg)
Introduction to MATLAB
Variable names
• Variable may have names that consist of characters and digits, but they can not start with a number!
• Matlab distinguishes between lower and upper cases - so A and a are different objects
• Only the first 19 characters in a variable name are important.
![Page 11: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/11.jpg)
Introduction to MATLAB
Try this!
• You have just created two vectors, x & y!• Now try some operations on them! (multiply
by a constant, use sin(x), sqrt(x), exp(x), …
![Page 12: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/12.jpg)
Introduction to MATLAB
Try this!
![Page 13: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/13.jpg)
Introduction to MATLAB
This is your first plot!
![Page 14: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/14.jpg)
Introduction to MATLAB
How about this?
![Page 15: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/15.jpg)
Introduction to MATLAB
Now, you know how to create a plot of your data!
![Page 16: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/16.jpg)
Introduction to MATLAB
Matrix Operations
• Try these:
![Page 17: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/17.jpg)
Introduction to MATLAB
Another way of creating a vector
• You may try to multiply, add, or invert those matrices!
![Page 18: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/18.jpg)
Introduction to MATLAB
Matrix Inversion
• Matrix inversion is performed using the function:inv();
![Page 19: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/19.jpg)
Introduction to MATLAB
What variables have you defined already ?
• Also try the commands: who & whos
![Page 20: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/20.jpg)
Introduction to MATLAB
More Matrix Operations
• Try these:
![Page 21: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/21.jpg)
Introduction to MATLAB
More Matrix Operations
![Page 22: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/22.jpg)
Introduction to MATLAB
Special Matrices!
![Page 23: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/23.jpg)
Introduction to MATLAB
Solving Equations!
• Now we may use the tools we have to solve a system of equations!
• If we have the equations:
• Just transform it into matrix form!632
892
735
zyx
zyx
zyx
![Page 24: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/24.jpg)
Introduction to MATLAB
Here is how!
![Page 25: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/25.jpg)
Introduction to MATLAB
Or Even Easier!!!
• Actually, if you are solving a large system of equations, this operator is MUCH faster!
![Page 26: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/26.jpg)
Introduction to MATLAB
The last function for today!
• Timing function:tic … toc
• Tic: starts the timer• Toc: stops the timer and gives you the time in
seconds!
![Page 27: Introduction to matlab](https://reader035.vdocuments.us/reader035/viewer/2022081400/555812d9d8b42ae31c8b569a/html5/thumbnails/27.jpg)
Introduction to MATLAB
More topics!
• Complex numbers• Working with files• More graphics• Programming• Symbolic Operations