Chapter 5_Strings.P1.pdf

# Chapter 5_Strings.P1.pdf - Introduction to Computer for...

This preview shows pages 1–7. Sign up to view the full content.

Strings Introduction to Computer for Engineers

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

View Full Document
A string is an array of characters s = 'abc‘ is equivalent to s = [ 'a' 'b' 'c' ] All operations that apply to vectors and arrays can be used together with strings as well s(1) 'a' s( [ 1 2 ] ) = 'XX' s = 'XXc' s(end) 'c'
Letter Digit a 97 b 98 c 99 d 100 e 101 f 102 g 103 h 104 i 105 j 106 k 107 l 108 m 109 Letter Digit n 110 o 111 p 112 q 113 r 114 s 115 t 116 u 117 v 118 w 119 x 120 y 121 z 122 Letter Digit A 65 B 66 C 67 D 68 E 69 F 70 G 71 H 72 I 73 J 74 K 75 L 76 M 77 Letter Digit N 78 O 79 P 80 Q 81 R 82 S 83 T 84 U 85 V 86 W 87 X 88 Y 89 Z 90

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

View Full Document
Symbol Digit 32 ! 33 34 # 35 \$ 36 % 37 & 38 39 ( 40 ) 41 * 42 + 43 , 44 Symbol Digit - 45 X. 46 / 47 0 48 1 49 2 50 3 51 4 52 5 53 6 54 7 55 8 56 9 57 Symbol Digit : 58 ; 59 < 60 = 61 > 62 ? 63 @ 64 [ 91 \ 92 ] 93 ^ 94 _ 95 ` 96 Symbol Digit { 123 | 124 } 125
Conversion of strings to numerical arrays double ( 'abc xyz' ) ans = 97 98 99 32 120 121 122 double ( 'ABC XYZ' ) ans = 65 66 67 32 88 89 90 Conversion of numerical arrays to strings char ( [ 72 101 108 108 111 33 ] ) ans = Hello!

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

View Full Document
ischar() : returns 1 for a character array ischar ( 'CS 111' ) ans = 1 isletter()
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern