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
Dimensions - matrix: The size and length functions in the MATLAB are used to find array dimensions. Length function returns the number of elements in the vector. The size func

Standard Deviation The standard deviation is the square root of variance: The built-in function in a MATLAB for the standard deviation is known as std; the standard dev

Writing and Reading Spreadsheet Files: The MATLAB functions xlswrite & xlsread will write to and read from the spreadsheet files which have the extension .xls. For illustratio

Common form of the switch statement: The common form of the switch statement is as shown below:   switch switch_expression   case caseexp1    action1   case cas

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

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

strvcat function - concatenation: The function strvcat will concatenate it vertically, that means that it will generate a column vector of the strings.   >> strvcat(fir

Differentiation: The derivative of a function y = f(x) can be written as follows or f  '(x) and is defined as the rate of change of the dependent variable y with respe

Built-in function for Differentiation: The MATLAB has a built-in function, diff that returns the differences between consecutive elements in a vector. For illustration, >>

Illustration of Writing variables to a file: For illustration, in the below session in the Command Window, 3 variables are generated; these are then exhibited using who. Then,