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
A matlab function to calculate filter order

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

Implementation of binary search: The binary search can be implemented as a recursive function. The recursive function below also implements this binary search algorithm. It re

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

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.

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

. Generate the following signal, x(n)=1+cos((25*pi*n)/100),0 Compute the DTFT of x[n] for w=0:0.01:2*pi Plot the Real part, imaginary part, the amplitude and phas

ischar function: The ischar function return the logical true if an array is a character array, or logical false if not. >> vec = 'EK127'; >> ischar(vec) ans =

Finding a sting - function strfind: The function strfind does necessarily similar thing, except that the order of the arguments does make dissimilarity. The common form is str

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