Chapter2-44 - Strings Strings...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
         Strings
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Strings Strings are strings of characters, eg.  letters, numbers, symbols, etc. Strings are easily written by enclosing  the characters in a  single quote.
Background image of page 2
String indexing The first character of a string has index  1 Examples: a='abcd', a(1) = 'a', a(2) = 'b',  etc A range of values is obtained with a  semicolon , a(2:3) = 'bc' Even backwards a(4:-1:2) = 'dcb'
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Concatenating Strings You can put two strings together  (concatenate) with brackets. old1 = 'ab'; old2 = 'cd'; old3 = 'ef'; Example: newstring=[old1,old2] or  newstr=['ab', 'cd']  This doesn’t have to end with just two  strings. Example: newstr=[old1,old2,old3]
Background image of page 4
String Functions length()  -  returns the number of characters strcmp()  - compares two strings str2num() - converts a string to numerical value abs() - gets the ascii code for the characters in a 
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 10

Chapter2-44 - Strings Strings...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online