Strings as vectors, MATLAB in Mathematics

Strings as Vectors:

The Strings are considered as vectors of characters-or in another words, a vector in which each and every element is a single character-so numerous vector operations can be performed. For illustration, the number of characters in a string can be found by using the length function:

 

>> length('cat')

ans =

3        

>> length(' ')

ans =

1

>> length('')

ans =

0

 

Notice that there is a distinction between an empty string, that has a length of zero, and a string consisting of a blank space, that has a length of one.

The Expressions can refer to a separate element, or a subset of a string or a transpose of the string:

>> mystr = 'Hi';

>> mystr(1)

ans =

H

>> mystr'

ans =

H

i

>> sent = 'Hello there';

>> length(sent)

ans =

11

>> sent(4:8)

ans =

lo th

 

Note that the blank space in the string is a valid character contained by the string.

Posted Date: 10/20/2012 4:29:39 AM | Location : United States







Related Discussions:- Strings as vectors, Assignment Help, Ask Question on Strings as vectors, Get Answer, Expert's Help, Strings as vectors Discussions

Write discussion on Strings as vectors
Your posts are moderated
Related Questions
If I have a vector representing the packed storage form of a symmetric matrix, how do I perform a cholesky factorisation on that?

Built-in functions for Complex numbers:   We know that in MATLAB both i and j are built-in functions which return √-1 (therefore, they can be thought of as built-in constants).

Using Functions with the Vectors and Matrices: As MATLAB is written to work with the vectors and matrices, the whole vector or matrix can be passed as an argument to the funct

how can reconstruct just part of an image using imreconstruct?

Illustration of logical built-in functions: The function find returns the indices of a vector which meet certain criteria. For illustration, to find all the elements in a vect

Types of User-defined Functions: We know how to write a user-defined function, stored in an M-file, which computes and returns one value. This is merely one type of the functi

Script a MATLAB program which meets the following speci cations: The program expects an input of a two-variable real-valued continuous function f : R^2--> R The program is to cal

Three-Dimensional Plots: The MATLAB has many functions which will display three-dimensional plots. Most of these functions have similar name as corresponding two-dimensional p

sprintf function: The sprintf function works precisely like the fprintf function, but rather than printing it generates a string. Here are some illustrations in which the outp

Illustration of Logical vectors: Calling the function appears to return similar vector as simply vec > 5, and summing the result still works to determine how many elements wer