SUNY Geneseo Department of Mathematics
Wednesday, April 27
Math 230 02
Spring 2016
Prof. Doug Baldwin
blanks
function adds blanks between strings, avoids typing
hard-to-see space character>> % Create some strings
>> s = 'This is a string'
s =
This is a string
>> size( s )
ans =
1 16
>> s2 = 'So is this'
s2 =
So is this
>> % Concatenate strings
>> [ s, s2 ]
ans =
This is a stringSo is this
>> [ s, blanks(1), s2 ]
ans =
This is a string So is this
>> % Pick a substring out of a string
>> s( 6:7 )
ans =
is
>> % Is s equal to "hello world"?
>> strcmp( s, 'hello world' )
ans =
0
>> s == 'hello world'
Error using ==
Matrix dimensions must agree.
strcmp
or a related function
to avoid unhelpful and often impossible element-by-element vector comparisonload
in the Matlab
command window (or a script) to load it into Matlab