Machine Learning--octave Matrix operation (2)--day3

Source: Internet
Author: User
Tags cos sin

Mathematical operations of matrices:

Assumed:a is a matrix,m is a vector

Log (a)--a logarithm of each element

Exp (a)--base e index

1./a--The mentor of every element

[A,b]=max (m)--m is a vector,a is the largest element in m , andb is a ordinal number in m (from small to large row)

M<3--such as m=[1 6 7], will be [1 0 0](should be able to understand)

Find (m>3)--such as m=[1 6 7], will get [2 3], that is , the subscript of the element greater than 3 (should be able to understand)

Magic (3)--produces a 3*3 matrix, with each row added equal to each column .

[C,d]=find (A>3)--Finds all elements greater than 3 in the a matrix , andC returns rows ,D returns the column

SUM (m)--Sum

Prod (m)--Product

Floor (m)--Rounding down

Ceil (m)--Rounding up

Max (a,[],1)--Take the maximum value of each column

Max (a,[],2)--Take the maximum value of each row

Sum (a) or sum (a,1)--Sum each column

SUM (a,2)--sum each line

SUM (SUM (A.*eye (3))-- a matrix of the diagonal elements of A and (a is a 3*3 )

Max (A (:))--Find The largest element in a matrix

Flipud (a)--Flips The matrix up and down

SUM (SUM (A.*flipud (eye (3)))-- The sum of a pair of diagonal elements (a is 3*3 The Matrix)

Drawing:

Plot (x, y)-- is the dependent variable andy is the argument

On

Plot (x1,y1, ' R ')--Put the picture above the old figure, the color is red

Xlabel (")--Give the argument a name

Ylabel (")--Give the dependent variable a name

Legend (",")--Legend

How to save a picture in MATLAB:

1, You can use the print command to save:
Print (1, '-djpeg ', ' picname.jpeg ')
Note: The first parameter represents the handle number of the graphics window, the second argument, in quotation marks, is saved in the JPEG format, and the third parameter is the file name.
2, can be saved with the SaveAs command:
SaveAs (GCF, ' picname ', ' jpg ')
Note: The first parameter is the function name Matlab obtains the graphics handle number, the second parameter, in quotation marks is the file name that you want to save, do not write the suffix here, the third parameter is the file type.

3.Figure (1);p lot (); --Numbering the graph

In 4.matlab, subplot (m,n,p) can draw an mxn Sub-chart in a figure, P can specify the position of the sub-graph, in general P is a single number,p is a vector can be combined with multiple sub-graphs as a sub-graph.

  1. Clear
  2. Clc
  3. X=-4*pi+eps:0.01:4*pi;
  4. Y1=sin (x);
  5. Y2=cos (x);
  6. Y3=tan (x);
  7. Figure
  8. Subplot (2,2,1);p lot (x,y1), title (' Sin (x) ')
  9. Subplot (2,2,2);p lot (x,y2), title (' cos (x) ')
  10. Subplot (2,2,[3,4]);p lot (x,y3), title (' Tan (x) ')% merges two of the second row into one
  11. Figure
  12. Subplot (2,2,[1 2]);p lot (x,y1), title (' Sin (x) ')% merges two of the first row into one
  13. Subplot (2,2,3);p lot (x,y2), title (' cos (x) ')
  14. Subplot (2,2,4);p lot (x,y3), title (' Tan (x) ')
  15. Figure
  16. Subplot (2,2,[1 3]);p lot (x,y1); title (' Sin (x) ')% merge two of the first column into one
  17. Subplot (2,2,2);p lot (x,y2), title (' cos (x) ')
  18. Subplot (2,2,4);p lot (x,y3), title (' Tan (x) ')
  19. Figure
  20. Subplot (2,2,1);p lot (x,y1), title (' Sin (x) ')
  21. Subplot (2,2,3);p lot (x,y2), title (' cos (x) ')
  22. Subplot (2,2,[2 4]);p lot (x,y3), title (' Tan (x) ')% merges two of the second column into one
  23. 5.axis ([1 2 3 4]) --Set x axis is ( the ), y The axis range is set to ( 3 , 4)

5.axis ([1 2 3 4])--Set the x axis to (+) and they - axis range to (3 , 4 )

6.Imagesc (a)--Visual matrix

7.Imagesc (a), Colorbar,clolormap gray; --Black and white (amount, bad description, as below)

Machine Learning--octave Matrix operation (2)--day3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.