MATLAB matrix operations

Source: Internet
Author: User

1: Find the number of rows nrow=size (matrix,1);

2: The number of columns ncol=size (matrix,2);

3: Matrix merge c1=[m1,m2] horizontal merge c2=[m1;m2] vertical merge

m1= [5 2 3]; M2=[1 2 3];

C1 =[5 2 3 1 2 3];

C2 =[

5 2 3
1 2 3

]

MATLAB subscript starting from 1, take the elements of Matlab directly with M[index] can

Take a sub-matrix

M[r1:rn,:] R1-rn row, all columns

M[:,C1-CN] C1-CN column, all rows

Number of elements in the statistical matrix that are equal to Q (ii)

OO (1,ii) =length (Find (H (:, i+1) ==q (ii));

4: Matrix transpose transpose (matrix) matrix ';

Matalab Logic Judgment

<, <=, >, >=, = =, ~=, &, |, ~

Decimal rounding

Ound (x): rounded to nearest integer
Fix (x): the decimal to the nearest integer, whether positive or negative
Floor (x): Rounding down, that is, rounding the positive decimal to the nearest integer
Ceil (x): Rounding up, that is, adding positive decimals to the nearest integer

Matlab sorting by rows
Sortrows (M, nrow);
Sortcols (M,ncol);

matlab Matrix Establishment : http://www.cnblogs.com/whxiyi/archive/2009/12/08/1619500.html

Diagonal matrix eye (n);

Empty Matrix []

Nan (' Double ') is the same as Nan with no parameters. Nan (' single ') is an Nannan (n) of the mono-precision expression (representation) that returns a n*n-composed matrix of Nan. Nan (m,n) or Nan ([m,n]) returns a m*n matrix that is composed of Nan.

MATLAB matrix operations

A (:, j) denotes column J of Matrix A

A (i,:) Represents the line I of matrix A

A+b: Matrix addition

A-B: Matrix subtraction

A*b: Matrix multiplication

a\b: Left divide of Matrix

A/b: right-of-matrix removal

Transpose (m) or M ' Matrix transpose

A (:, j) denotes column J of Matrix A.

A (i,:) Represents the line I of matrix A.

A (I,J) represents the first row of column J of the matrix A element.

A (i) represents the first element of matrix A (:).

Each element of the m.^2 matrix is evaluated two times

Logical judgment

while (Iter<iter_max) && (Err>err_max)

MATLAB matrix operations

Related Article

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.