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

Example of exponential function modular program, Example of Exponential fun...

Example of Exponential function modular program: In order to view the distinction in the approximate value for e as n increases, the user kept choosing Limit & entering larger

Function used in sound files, Function used in sound files: The MATLAB...

Function used in sound files: The MATLAB has numerous other functions which let you read and play sound or audio files. In the audio files, sampled data for each audio channel

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

Algorithm for the function e, Algorithm for the function e: The algori...

Algorithm for the function e: The algorithm for the function eoption is as shown: Use the menu function to show the 4 choices. Error-check (an error would take place

Plotting from a function, Plotting from a Function: The following func...

Plotting from a Function: The following function creates a Figure Window as shown in figure, which shows various types of plots for similar y vector. The vector is passed as a

Illustration of finding a sting, Illustration of finding a sting: Le...

Illustration of finding a sting: Let's enlarge this, and write a script which creates a vector of strings which are phrases. The outcome is not suppressed so that the string

Matrix multiplication, Matrix Multiplication: The Matrix multiplicatio...

Matrix Multiplication: The Matrix multiplication does not mean multiplying term by term; and it is not an array operation. The Matrix multiplication has a very particular mean

Evaluating a string, Evaluating a string: The function eval is used to...

Evaluating a string: The function eval is used to compute a string as a function. For illustration, below is the string 'plot(x)'is interpreted to be a call to plot the functi

Removing whitespace characters, Removing Whitespace Characters: The MA...

Removing Whitespace Characters: The MATLAB has functions which will eliminate trailing blanks from the end of a string and/or leading blanks from the starting of a string.

Illustration of variable scope, Illustration of Variable scope: Runnin...

Illustration of Variable scope: Running this function does not add any of variables to the workspace, as elaborated: >> clear >> who >> disp(mysum([5 9 1]))

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