MATLAB study notes (2)-cell function, whos function, class function

[Syntax description]

  • Unit ( the Cell ) is a generalized matrix array. Each element is called a unit. Each unit can be an arbitrary array, such as a numeric array, string array, structure array or another unit array. Each cell array can have a different size and memory footprint. The array can be created by assignment statement or cell function. It should be noted that the cell array is created with curly braces "{ }".

  • whos function: can list all variables in the current workspace, as well as their size, bytes, class and other information. The wildcard "*" can be used to display matching variables, such as whos A* finds all variables that start with A in the current workspace. S = whos(...) returns a structure with fields.

  • class function: S = class(OBJ) returns the class name of the object OBJ, such as double double-precision floating-point number array, single single-precision floating-point number array, logical logic array, char character array, cell unit array, struct structure array, function_handle function handle .

[Example description]

a={‘x’ [1 3 5]’;{‘x’ [1 3 5]’} 0}

a =

'x'           [3x1 double]
{1x2 cell}    [         0]

whos a

 Name      Size      Bytes    Class    Attributes
    a       2x2        732     cell      

class(a)

years =

cell

class(a{1})

years =

char

class(a{2})

years =

cell

Guess you like

Origin blog.csdn.net/weixin_42467801/article/details/104709825