Reputation: 2072
In octave what is the difference between log(a) and log a?
>>a
a =
1 2
>>log(a)
ans =
0.00000 0.69315
>>log a
ans = 4.5747
Upvotes: 1
Views: 422
Reputation: 18952
In the second example, Octave is interpreting 'a'
as a char, converting 'a'
to its ASCII representation (97) and then getting the natural logarithm.
log(97) = 4.5747
In general you have two ways to call functions: as a function or as a command. E.g.
save('test.txt')
save test.txt
When a function is used as a command, it assumes the input is a string.
Anyway newer version of Matlab and Octave have an error check for character input (there is little reason to compute the logarithm of the ASCII equivalent of a character).
Upvotes: 2