Matlab brackets and Matlab brackets

Source: Internet
Author: User

Matlab brackets and Matlab brackets

Http://blog.csdn.net/pipisorry/article/details/39215767

In Matlab, brackets are used to reference the content of an Array or cell. The differences between the three are as follows:

Braces are used to assign values to cell arrays. brackets are used to form a vector or matrix. Parentheses are usually used in general arithmetic expressions to indicate priority. They are also used to represent function variables, vector subscripts, and matrix subscripts.


[]
Brackets are used to construct Vectors or Matrices ). For example
[6.9 9.64 sqrt (-1)] is a vector with three elements.[11 12 13; 21 22 23]Is a two-by-three matrix. semicolon (;) is used to end a row.
Another function of brackets is to allocate output parameters in a function.

The role of [] in the square brackets of Matlab 1. Definition matrix (vector, array ). For example, a = [1 2 3; 4 5 6] 2. define the list of return parameters of the function (output variable count ). For example, [m, n] = size (a) If the function returns only one parameter, brackets are generally omitted. That is, [n] = rand (1, 2); writeable n = rand (1, 2 );


{}
Braces are used to allocate or reference cell-type arrays.
For example
  A(2,1) = {[1 2 3; 4 5 6]}, Or A{2,2} = ('str')



()
Parentheses are used to reference elements of an array.
For example, X (3) is the third element of X.X ([1 2 3]) is the first three elements of X.

Example:
A = [1 2 3]
% A is A numerical array of three elements. Brackets are used to construct a non-cell array.
% Array references are enclosed in parentheses
A (1, 1)
% A (1, 2) gets the elements in the second column of the first row of array.

B = {}
% B is an array of one row and two columns. The element of the array is cell.
% Array references still use parentheses
B (1)
% B (1) is a cell.
The reference of % cell content must be in braces.
% B {1} indicates the content of cell 1, which is 1 2 3.
If the content of % cell is a numeric array, reference the content with parentheses

B {1} (1, 3)
The content of % B {1} (1, 3) is 3.

D = {B}

D =

   {1x2 cell}  {1x2 cell}

In this case, the reference of an element of D is
D {1} {1, 2} (1)
% Cell layers must be referenced in braces.

The relationship between arrays and metadata in Matlab is as follows:




From: http://blog.csdn.net/pipisorry/article/details/39215767

Ref:

Help cell
Help paren

The function of Matlab square brackets "[]" http://www.advancedmcode.org /? P = 2921 & preview = true




How to input brackets in matlab

Two [] Next to keyboard P

How to enclose brackets in matlab

Next to the enter key

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.