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

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

Modular programs: In a modular program, the answer is broken down into modules, and each is executed as a function. The script is usually known as the main program. In orde

Plotting File data: It is frequently essential to read data from a file and plot it. Generally, this entails knowing the format of the file. For illustration, let us suppose t

Vectors of Structures: In numerous applications, involving database applications, information generally would be stored in the vector of structures, instead of in individual s

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

Binary Search: The binary search supposes that the vector has been sorted first. The algorithm is just similar to the way it works whenever looking for a name in a phone direc

Finding a sting - function findstr: The function findstr receives two strings as input arguments. It finds all the occurrences of shorter string contained by the longer, and r

Dot Product: The dot or inner product of two vectors a and b is written as a • b and is defined as  In another words, this is like matrix multiplication when multiplyi

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