In debugging some code I found the following results confusing. Anyone know how to further investigate this? Or do I simply need to avoid dividing a number by itself? I thought MatLab was "smart" enough to use 1 for the fraction of CF/CF. BTW I'm using R2014a student version on a mid 2009 Mac book pro with OSX 10.9.2
Here is the actual code that causes problems only some of the time as this is inside a function that is called 1000's of times but this error only happens a handful of them.
PL=fzero(@(y)(...
(s.State(6).H-s.State(4).H)*M_Dot/eta_pump...
-y*CVTModel_NV(RPM_Pump/RPM_Exp,y/CF)),[0.2*CF CF])/CF;
This is what I did at the command prompt in debugger mode at the line.
CVTModel_NV(RPM_Pump/RPM_Exp,0.2*CF/CF)
ans =
NaN
K>> CVTModel_NV(RPM_Pump/RPM_Exp,0.2)
ans =
0.828663580586898
K>> 0.2*CF/CF
ans =
0.200000000000000
K>> CVTModel_NV(RPM_Pump/RPM_Exp,ans)
ans =
NaN
K>> CF
CF =
2.669084425186238e+03
K>> CVTModel_NV(RPM_Pump/RPM_Exp,0.200000000000000000000)
ans =
0.828663580586898
At this point I commented this line out of the function CVTModel_NV:
Eff(SR>2|SR<0.5|PL<0.2|PL>1)=NaN;
And then got the following results:
K>> CVTModel_NV(RPM_Pump/RPM_Exp,0.2*CF/CF)
ans =
0.828663580586898
Then further testing reviled the problem.
K>> CF/CF
ans =
1
K>> 0.2*CF/CF<0.2
ans =
1
K>> 0.2*CF/CF==0.2
ans =
0