It seems like both inf and Inf are exactly same in MATLAB (likewise nan and NaN, but not Nan). Is there any difference?
>> which inf
built-in (/Applications/MATLAB_R2011b.app/toolbox/matlab/elmat/inf)
>> which Inf
built-in (/Applications/MATLAB_R2011b.app/toolbox/matlab/elmat/Inf)
If they are the same, which one should be used in practice? For allocating arrays I have been using x = inf(3,5) style following zeros and ones being all small caps. For assigning single value, I use x = Inf. Do you think this is a consistent use?
Here are the conventions that MATLAB appears to use:
For Not-a-Number: Always use
NaN(Except in combinations such asisnan()For Infinite: Use
inffor the function and useInffor the value (andINFsfor multiples, but this is not a command of course). Note that this is a bit tricky as it means that the evaluation ofinfgivesInf.Deduced from:
help Inf: inf(N) is an N-by-N matrix of INFs.help nan: NaN(N) is an N-by-N matrix of NaNs.help isnan: For example, isnan([pi NaN Inf -Inf]) is [0 1 0 0].