1 / 20

Lec-10 Manipulations of Matlab Matrices

Lec-10 Manipulations of Matlab Matrices. Built-in functions. The chapter will be covered quickly There are quite a few built-in functions in MATLAB If you can think of it, it is probably available To find documentation, use Google to find documentation: e.g. google “sine matlab”

kane
Download Presentation

Lec-10 Manipulations of Matlab Matrices

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lec-10Manipulations of Matlab Matrices

  2. Built-in functions • The chapter will be covered quickly • There are quite a few built-in functions in MATLAB • If you can think of it, it is probably available • To find documentation, use Google to find documentation: e.g. google “sine matlab” google “standard deviation matlab”

  3. Nesting of functions • Just in regular math where one can use f(g(x)) • Arguments can be scalars, vectors or matrices

  4. Parameters (Arguments) Parameter and argument are almost synonyms sqrt(x) is a function with one parameter If we call sqrt as sqrt(4) 4 is the argument passed to the parameter sin(x) is a function of one parameter too If we call it as sin(sqrt(4)) It’s the value of sqrt(4) is passed as the argument to its one parameter.

  5. Functions with multiple arguments • We have encountered linspace(1,10,100) • rand(3,4) • rem(12.1,5.0) ans= 2.1

  6. Matlab help • You can use MATLAB help • If you don’t know the name, use Google. • Try “help” tab in MATLAB window.

  7. More MATLAB Functions

  8. Rounding Functions

  9. Trigonometric Functions • sin(x) sine of x expressed in radians) • cos(x), tan(x) • sind(x) sine of x in degrees • cosd(x) • tand(x) etc.

  10. Data Analysis Functions • max (maximum) • min (minimum) • mean (average) • median • sum (sum total of elements) • prod (product) • sort (sort elements) • cumsum, cumprod (cummulative sum, prod)

  11. mean

  12. sum and cumsum

  13. Example of mean with vector output

  14. If you can imagine it, it is likely there

  15. Sorting

  16. Try • Try out at least 10 of the functions I just described with both scalar and vector inputs • At least one of fix, round, ceil • At least one of the trig functions in radians and degrees. • Some of the sum, prod, cumsum • Try log of exp • Try max with vector output • Compute the average location of the maximum values from the columns of the matrix magic(5) • Sort the rows of magic(5) according to the third column

  17. Problem Problem 3.20: • Throw one die • Throw two dice • Throw two dice 100 times along with the total of each throw • Histogram the sum

  18. Problem >> one=floor(rand(1)*6+1) one = 5 >> two=floor(rand(1,2)*6+1) two = 2 4 >> sim=floor(rand(2,10).*6+1) sim = 1 2 5 3 2 1 4 1 1 1 4 4 5 1 6 5 6 3 6 5 >> total=sum(sim) total = 5 6 10 4 8 6 10 4 7 6 >> hist(total);

  19. Problem

  20. Problem

More Related