Graphics Programs Reference
In-Depth Information
>> c
{
1
}
(2)
% Second element of first cell
ans =
2
{
>> c
2
}
% Second cell
ans =
one two three
Strings
A string is a sequence of characters;it istreatedbyMATLABas a character array. Strings
arecreatedbyenclosing the characters between single quotes. Theyareconcatenated
with the function strcat , whereas a colon operator ( : ) is used to extract aportion of
the string. For example,
>> s1 = 'Press return to exit';
% Create a string
>>s2='theprogram';
%Createanotherstring
>> s3 = strcat(s1,s2)
% Concatenate s1 and s2
s3 =
Press return to exit the program
>> s4 = s1(1:12)
% Extract chars. 1-12 of s1
s4 =
Press return
1.3
Operators
Arithmetic Operators
MATLAB supports the usual arithmeticoperators:
+
Addition
Subtraction
Multiplication
ˆ
Exponentiation
When applied to matrices, theyperform the familiar matrix operations, as illus-
tratedbelow.
>>A=[123;456];B=[789;012];
>>A+B
%Matrixaddition
Search WWH ::




Custom Search