MATLAB base operator and data format display

Source: Internet
Author: User

1. Colon ":"

The basic use is as follows:

x=1:10; vector generation [1,2,3,4,5,6,7,8,9,10]

x=j:i:k; expression vector [j,j+i,j+2i,..., K];

A (:, j); Represents the column J of Matrix A

A (i,:); indicates that row I of matrix A is taken

A (J:K); Equivalent to A (j), A (j+1),... A (k)

A (:); Turns all matrices of a into a column vector

2. Percent percent "%"

% comment in m file and command line

3. Serial number "..."

If one line of commands is long, you can use 3 or more points at the end of this line to indicate that the line is not complete and that the next line continues.

Display of data formats:

Data storage in MATLAB is stored in double-precision. However, the display format can be different. Use the Format command to adjust the formatting.

(1) Format: Default value, data display is the same as short

(2) Format short: only 5 digits are displayed. Integers are displayed in the original format of the data, and the decimal number displays only 4 bits. For example 123.45678 shows 123.4568.

(3) Format long: Long format, displaying 15 digits.

(4) Format hex:16 binary display

(5) Format Bank: currency type. Keep two digits after the decimal point

(6) Format rat: The rational number form is displayed. 0.3333 ... will show 1/3,0.5 and 1/2 will show 1/2

(7) Format Compact: compact format

MATLAB base operator and data format display

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.