Showing cell array elements and attributes, MATLAB in Engineering

Assignment Help:

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


Related Discussions:- Showing cell array elements and attributes

Finding products by for loop, Finding products by for loop: an illustr...

Finding products by for loop: an illustration, when 5 is passed to be the value of the input argument n, the function will compute and return 1 + 2 + 3 + 4 + 5, or 15: >> s

Replacing, Replacing, Finding, and separating strings: There are numer...

Replacing, Finding, and separating strings: There are numerous functions which find and replace the strings, or parts of strings, within the other strings and functions which

Matrix solutions of the linear algebraic equation, Matrix solutions to syst...

Matrix solutions to systems of the linear algebraic equations: The linear algebraic equation is an equation of the form a 1 x 1 + a 2 x 2 + a 3 x 3    .  .  .  .  a n x n

Function call - modular program, Function call: In the function call, ...

Function call: In the function call, not any arguments are passed so there are no input arguments in the function header. The function returns an output argument, therefore th

Set operations, Set Operations: The MATLAB has numerous built-in funct...

Set Operations: The MATLAB has numerous built-in functions which perform set operations on vectors. These involve intersect, union, setdiff, unique, and setxor. All these func

Executing a program - modular program, Executing a program: Running th...

Executing a program: Running the program would be completed by typing the name of the script; this would call the other functions: >> calcandprintarea Whenever prompt

Image processing, Image Processing: The Images are represented as grid...

Image Processing: The Images are represented as grids, or matrices, of picture elements (known as pixels). In MATLAB an image usually is represented as a matrix in which each

Variable scope, Variable Scope: The scope of any of variable is the wo...

Variable Scope: The scope of any of variable is the workspace in which it is valid. The workspace generated in the Command Window is known as the base workspace. As we know

Built-in colormaps - image processing, Built-in colormaps: The MATLAB ...

Built-in colormaps: The MATLAB has numerous built-in colormaps which are named; the reference page on colormap shows them. Calling the function colormap without passing any ar

Function cellplot - cell array, Function cellplot - Cell array: The fu...

Function cellplot - Cell array: The function cellplot place a graphical display of the cell array in a figure Window; though, it is a high-level view and fundamentally just di

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd