Showing cell array elements and attributes, MATLAB in Engineering

Referring to and Showing Cell Array Elements and Attributes:

Just as with the other vectors, we can refer to individual elements of the cell arrays. The only difference is that the curly braces are used for the subscripts. For illustration, this refers to the second element of the cell array cellrowvec:

> cellrowvec{2}

ans =

a

 

The Row and column indices are used to refer to an element in a matrix for illustration,

>> cellmat{1,1}

ans =

23

 

The Values can be assigned to cell array elements. For illustration, after preallocating the variable mycellmat, the elements can be initialized:

>> mycellmat{1,1} = 23

mycellmat =

[23]  []

[]  []

 

Whenever an element of a cell array is itself a data structure, then only the type of the element is displayed when the cell array contents are shown. For illustration, in the cell arrays just generated, the vector is shown just as 1 × 5 double. Referring to that element particularly would display its contents, the illustration is as follows,

>> cellmat{2,1}

ans =

  1   3   5   7   9

 

As this element is a vector, the parentheses are used to refer to its elements. For illustration, the fourth element of the preceding vector is as shown below:

>> cellmat{2,1}(4)

ans =

  7

Note that the index in the cell array is given in the curly braces, and then parentheses are used to refer to an element of the vector.

We can also refer the subsets of cell arrays, for illustration,

>> cellcolvec{2:3}

ans =

a

ans =

  1   3   5   7   9

 

Note, though, that MATLAB stored cellcolvec{2} in the default variable ans, and then substituted that with the value of cellcolvec{3}. This is because the two values are of various types, and hence cannot be stored altogether in ans.

Though, they could be stored in two separate variables by having a vector of variables on the left-hand side of the assignment.

>> [c1 c2] = cellcolvec{2:3}

c1 =

a

c2 =

  1   3   5   7   9

Posted Date: 10/20/2012 5:47:50 AM | Location : United States







Related Discussions:- Showing cell array elements and attributes, Assignment Help, Ask Question on Showing cell array elements and attributes, Get Answer, Expert's Help, Showing cell array elements and attributes Discussions

Write discussion on Showing cell array elements and attributes
Your posts are moderated
Related Questions
Illustration of gauss-jordan elimination: An illustration of interchanging rows would be r1 ¬→ r3, that would results: Now, beginning with this matrix, an illustration of sc

Storing Strings in Cell Arrays: The one good application of a cell array is to store strings of various lengths. As cell arrays can store various types of values in the elemen

Indexing into Vectors of structures: Frequently, when the data structure is a vector of structures, it is essential to iterate through the vector in order by various fields. F

Appending variables to the Mat-File: Appending to the file adds to what has been saved in a file, and is accomplished by using the -append option. For illustration, supposing

Reading from a Mat-File: The load function is used to read from various types of files. As with save function, by default the file will be supposed to be a MAT-file, and load

Calling of Function polyval: The curve does not appear very smooth on this plot, but that is as there are only five points in the x vector. To estimate the temperature

Related Structure Functions: There are many functions which can be used with structures in a MATLAB. The function isstruct will return 1 for logical true when the variable arg

Example of Gauss-jordan: For a 2×2 system, this would results and for a 3 × 3 system, Note that the resulting diagonal form does not involve the right-most col

Symbolic Variables and expressions: The MATLAB has a type known as sym for the symbolic variables and expressions; these work with strings. The illustration, to generate a sym

Replacement : Replace a row by adding it to (or subtract from it) a multiple of the other row. For a given row ri, this is written as   ri  - srj →  ri Note that when r