How to increase the precision in my output using structures
Mostrar comentarios más antiguos
Hi guys,
I'm running a program that needs more precision in the output. I have tried to use format long, but the output using the structure still reports without decimal places. Any suggestions?
Thanks
>> a = 3e-6*(s(1).pixels(2)).^2 + 0.0097*(s(1).pixels(2)) + 2.8827
a =
8
>> s(1).pixels(2)
ans =
531
>> a = 3e-6*(531).^2 + 0.0097*(531) + 2.8827
a =
8.8793
Respuestas (1)
James Tursa
el 20 de Abr. de 2015
Editada: James Tursa
el 20 de Abr. de 2015
I would assume s(1).pixels is some type of integer class instead of double, so you are getting an integer result. Either convert s(1).pixels to double first, or wrap the access with a double in the calculation. E.g.,
s(1).pixels = double(s(1).pixels);
or
a = 3e-6*(double(s(1).pixels(2))).^2 + 0.0097*(double(s(1).pixels(2))) + 2.8827
Categorías
Más información sobre Arithmetic Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!