Why is matlab not computing this correctly?
Afficher commentaires plus anciens
How is it that matlab does not calculate this correctly. I do not understand. what am I doing wrong here?
for T=295.45
c0=0.99999683;
c1=-0.90826951*10^(-2);
c2=0.78736169*10^(-4);
c3=-0.61117958*10^(-6);
c4=0.43884187*10^(-8);
c5=-0.29883885*10^(-10);
c6=0.21874425*10^(-12);
c7=-0.17892321*10^(-14);
c8=0.11112018*10^(-16);
c9=-0.30994571*10^(-19);
E=(c0+T*(c1+T*(c2+T*(c3+T*(c4+T*(c5+T*(c6+T*(c7+T*(c8+T*(c9))))))))));
end
the answer answer should be E=0.8308! but why is matlab giving me -137.0354? I got the correct answer by copying and pasting the same code into a different program..any help?
2 commentaires
Azzi Abdelmalek
le 24 Oct 2013
What do you mean by different program?
dpb
le 24 Oct 2013
Excel??? :)
Réponses (2)
Azzi Abdelmalek
le 24 Oct 2013
Modifié(e) : Azzi Abdelmalek
le 24 Oct 2013
Why are you expecting 0.8308? the correct answer is -137.0354, you can find it with the for loop:
v=[c9,c8,c7,c6,c5,c4,c3,c2,c1,c0];
E=0;
for k=1:numel(v)-1
E=(E+v(k))*T;
end
E=E+v(end)
dpb
le 24 Oct 2013
I'm guessing because you're evaluating the correlation for the wrong T -- generally these are either reduced temperatures or differentials -- let's see
>> T0=295.45;
>> T=T0-273.15;
>> E=(c0+T*(c1+T*(c2+T*(c3+T*(c4+T*(c5+T*(c6+T*(c7+T*(c8+T*(c9))))))))))
E =
0.8308
>>
That look more better????
Just for checkin'...
>> T=T0/273.15;
>> E=(c0+T*(c1+T*(c2+T*(c3+T*(c4+T*(c5+T*(c6+T*(c7+T*(c8+T*(c9))))))))))
E =
0.9903
>>
Ay-yup, looks like differential from reference not reduced presuming your other evaluation is the correct answer, of course! :)
1 commentaire
Armel
le 24 Oct 2013
Catégories
En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!