SUNY Geneseo Department of Mathematics
Monday, April 27
Math 230 02
Spring 2015
Prof. Doug Baldwin
randi
and char
functions>> char(65)
ans =
A
>> nums = randi( 255, [1 10] )
nums =
208 231 33 233 162 25 72 140 245 247
>> char( nums )
ans =
-Á!È¢ Hå1~
input
functionlength
, indexing, size
strcat
char
functionsprintf
creates string instead of printing ?deblank
removes blanks from endstrtrim
removes leading and trailing blanksupper
and lower
change casestrcmp
, returns 1 if equal, 0 if notstrrep
>> blanks( 3 )
ans =
>> length(ans)
ans =
3
>> s = 'hello world'
s =
hello world
>> fprintf( 'My string is "%s" of length %f\n', s, length(s) );
My string is "hello world" of length 11.000000
>> formatted = sprintf('My string is "%s" of length %f', s, length(s) );
>> formatted
formatted =
My string is "hello world" of length 11.000000
>> length(formatted)
ans =
46
>> formatted( 10:20 )
ans =
is "hello
>> x = pi/2
>> x =
1.5708
>> stringx = sprintf('%s',x)
stringx =
1.570796e+00
>> stringx2 = sprintf( '%f', x )
stringx2 =
1.570796
>> stringx2 + 17
ans =
66 63 70 72 65 72 74 71
>> stringx2 + 0
ans =
49 46 53 55 48 55 57 54
>> load fairytale
>> load courseDescription
>> play(fairyTale)
Give me a...
Adjective favorite
Verb Ending in "ing" spelunking
Adjective purple
Noun flower
Past-Tense Verb grew
Adjective short
Noun door
Adjective shiny
Verb smile
Noun puppy
Adverb quickly
Beverage coolaid
Once upon a time there was a favorite prince. One day, while the prince was spelunking
he met a purple wizard disguised as a flower. Not realizing what he was doing, the
prince grew the wizard. This made the wizard very short. In a twinkling of an eye,
he turned the prince into a door. "Never mind," thought the prince, "surely a shiny
princess will come along and smile me so I turn back into a puppy. Alas! Little did
the prince know that all the princesses were busy getting college degrees, while the
princes quickly sat around drinking coolaid. The end.
>> play( courseDescription )
Give me a...
Subject of Study ... etc ...