Why is matlab not computing this correctly?

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 Kommentare

Azzi Abdelmalek
Azzi Abdelmalek am 24 Okt. 2013
What do you mean by different program?
dpb
dpb am 24 Okt. 2013
Excel??? :)

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Azzi Abdelmalek
Azzi Abdelmalek am 24 Okt. 2013
Bearbeitet: Azzi Abdelmalek am 24 Okt. 2013

0 Stimmen

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
dpb am 24 Okt. 2013

0 Stimmen

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 Kommentar

Armel
Armel am 24 Okt. 2013
You are absolutely right..my Temperature T shouldn't have been in Kelvin but in celsius! so T=295.45K = 22.3C. I should have used 22.3 for the matlab..for whatever reasons I overlooked that. Thanks

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Hilfe-Center und File Exchange

Produkte

Tags

Noch keine Tags eingegeben.

Gefragt:

am 24 Okt. 2013

Kommentiert:

am 24 Okt. 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by