Creating cell arrays, MATLAB in Engineering

Creating Cell arrays:

There are many ways to create cell arrays. For illustration, we will create a cell array in which one element will store an integer, one element store character, one element store vector, and one element will store a string. Just as with the arrays, this could be a 1 × 4 row vector, a 4 × 1 column vector, or a 2 × 2 matrix. The syntax for generating vectors and matrices are same. The values within rows are separated by spaces or commas, and rows are separated by the semicolons. Though, for cell arrays, curly braces are used instead of square brackets. For illustration, the following creates a row vector cell array with the four distinct values:

>> cellrowvec = {23, 'a', 1:2:9, 'hello'}

cellrowvec =

  [23]  'a'  [1x5 double]   'hello'

To generate a column vector cell array, the values are rather separated by semicolons:

>> cellcolvec = {23; 'a'; 1:2:9; 'hello'}

cellcolvec =

[  23]

'a'

[1x5 double]

'hello'

This technique creates a 2 × 2 cell array matrix:

>> cellmat = {23 'a'; 1:2:9 'hello'}

cellmat =

[  23]         'a'

[1x5 double]   'hello'

Posted Date: 10/20/2012 5:45:11 AM | Location : United States







Related Discussions:- Creating cell arrays, Assignment Help, Ask Question on Creating cell arrays, Get Answer, Expert's Help, Creating cell arrays Discussions

Write discussion on Creating cell arrays
Your posts are moderated
Related Questions
Splits a string : The strtok function splits a string into pieces; it can be called in many ways. The function receives one string as an input argument. It appears for the fir

Matrix definitions: As we know the matrix can be thought of as a table of values in which there are both rows and columns. The most common form of a matrix A (that is sometime

Example of Plotting from a Function: For illustration, the function can be called as shown below:      >> y = [1:2:9].^3      y =     1  27  125  343  729

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

Passing Structures to Functions: The whole structure can be passed to a function, or separate fields can be passed. For illustration, here are the two distinct versions of a f

True color matrice: The true color matrices are the other way to represent images. The true color matrices are 3-dimensional matrices. The first two coordinates are the coordi

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

IS Functions for Strings: There are many functions for strings, that return logical true or false. The function isletter returns the logical true when the character is a lette

Finding sums and products: A very general application of a for loop is to compute sums and products. For illustration, rather than of just printing the integers 1 through 5, w

Algorithm for subfunction: The algorithm for subfunction askforn is as shown:  Prompt the user for the positive integer n.  Loop to print an error message and reprom