change in loop calculation and manual calculation

1 vue (au cours des 30 derniers jours)
Mudasir Ahmed
Mudasir Ahmed le 9 Juil 2015
Modifié(e) : James Tursa le 9 Juil 2015
hi
i want to calculate the following expression for below given values. when these values are putted in the loop, the response i get is slight different when compare it with manual calculation
angle = 0.5421 0.7166 0.8906 1.0647 1.2385
m=0
v1=(4/pi)*(vdc(1,1)*cos(angle(n,1))+vdc(1,2)*cos(angle(n,2))+vdc(1,3)*cos(angle(n,3))+vdc(1,4)*cos(angle(n,4))+vdc(1,5)*cos(angle(n,5))-m*5)
v1 = 97.1028
v1=(4/pi)*(vdc(1,1)*cos( 0.5421)+vdc(1,2)*cos(0.7166 )+vdc(1,3)*cos( 0.8906 )+vdc(1,4)*cos( 1.0647)+vdc(1,5)*cos( 1.2385 )-0*5)
v1 = 97.1035
if any one knows why this happen? kindly help me

Réponse acceptée

James Tursa
James Tursa le 9 Juil 2015
Modifié(e) : James Tursa le 9 Juil 2015
I think you will find that angle has more significant digits than you are printing. E.g., do this
format long g
angle
And you will likely see they are different than the truncated numbers you entered manually.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by