SUNY Geneseo Department of Mathematics
Friday, December 5
Math 230 01
Fall 2014
Prof. Doug Baldwin
>> name = 'Isaac Newton';
>> number = 3;
>> name == number
ans =
Columns 1 through 10
0 0 0 0 0 0 0 0 0 0
Columns 11 through 12
0 0
>> name2 = 'Alan Turing';
>> name == name2
{Error using ==
Matrix dimensions must agree.
}
>> strcmp(name,name2)
ans =
0
>> name3 = 'Isaac Newton';
>> strcmp(name,name3)
ans =
1
>> strcmp(number,3)
ans =
0
>> number
number =
3
>> cmp = @(x,y) length(x) == length(y) && x == y
cmp =
@(x,y)length(x)==length(y)&&x==y
>> cmp(name,name2)
ans =
0
>> cmp(name,number)
ans =
0
>> cmp(name,name3)
{Operands to the || and && operators must be convertible to
logical scalar values.
Error in @(x,y)length(x)==length(y)&&x==y
}
>> name3
name3 =
Isaac Newton
>> name
name =
Isaac Newton
>> name == name3
ans =
Columns 1 through 9
1 1 1 1 1 1 1 1 1
Columns 10 through 12
1 1 1
>> all(name==name3)
ans =
1
>> cmp = @(x,y) length(x)==length(y) && all(x==y)
cmp =
@(x,y)length(x)==length(y)&&all(x==y)
>> cmp(name,name3)
ans =
1
>> cmp(name,name2)
ans =
0
>> cmp(name,number)
ans =
0
>> isequal(name,name2)
ans =
0
>> isequal(name,name3)
ans =
1
>> isequal(name,number)
ans =
0
>> number
number =
3
>> cmp(number,'3')
ans =
0
>> cmp(3,'3')
ans =
0
>> length('3')
ans =
1
>> length(3)
ans =
1