How to increase the precision in my output using structures
Show older comments
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
Answers (1)
James Tursa
on 20 Apr 2015
Edited: James Tursa
on 20 Apr 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
Categories
Find more on Arithmetic Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!