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

Example of image processing: The other illustration generates a 5 × 5 matrix of arbitrary integers in the range from 1 to the number of colors; the resultant image is as shown

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.

Example of Interpolation and extrapolation: The MATLAB has a function to do this, known as polyfit. The function polyfit finds the coefficients of the polynomial of the partic

Uses of Function handles: The Function handles can also be generated for functions other than anonymous functions, both built-in & user-defined functions. For illustration, th

Algorithm for expfn function: The algorithm for expfn function is as shown:  receives the value of x as the input argument.  Prints the value of exp(x).  assigns a

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

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

Initializing the data structure - Function: Function is shown as:   >> printcylvols(cyls) Cylinder x has a volume of 169.6 Cylinder a has a volume of 100.5

num2str function: The num2str function, that converts real numbers, can be called in many ways. If only the real number is passed to the num2str function, it will generate a s