Cell (unit) data cell [Z]

Source: Internet
Author: User

Cell type (unit in some books) data is a special data type of MATLAB. It is flexible and can store arrays of different data types (characters, numbers) and different dimensions.
There are two ways to create:
1. Value assignment statement: assign a value directly to a unit, for example:
The subscript of the Content Index variable is enclosed in braces {}.
A {1, 1} = [1 2 3 4 5];
A {1, 2} = {'China'; 'yunnan '};
A {2, 1} = [1 + 1 * I, 4 * I]
The data in the unit index unit is enclosed by braces {}, and the unit subscript is enclosed by a common subscript.
A (1, 1) = {[1 2 3 4 5]};
A (1, 2) = {'China'; 'yunnan '}};
A (2, 1) = {[1 + 1 * I; 4 * I]}
2. Use the cell function: Cell Function to specify the cell size. You can assign values to the cell size after creation.
A = cell (2, 2)
View unit content
>
A =
[1x5 double] {2x1 cell}
[2x1 double] []
The above only shows the data structure. If you want to display the content, use celldisp
> Celldisp ()
A {1, 1} =
1 2 3 4 5
A {2, 1} =
1.0000 + 1.20. I
0 + 4. I I
A {1, 2} {1} =
China
A {1, 2} {2} =
Yunnan
A {2, 2} =
[]

 

The following is a summary of the confusing {}, [], ():

1) A = {'sy1', 'sy2', 'sy3'}; A is 1*3 cell

2) B = a B is 1*3 cell
3) B = [a] B is 1*3 cell

4) B = {A} B is 1*1 cell, B is only one cell of element , this element is still a 1*3 cell
5) C = B (1) c is 1*1 cell
6) D = B {1} D is 1*3 cell
7) d {1} d {1} is 'sy1'

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.