How to increase the precision in my output using structures
이전 댓글 표시
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
답변 (1개)
James Tursa
2015년 4월 20일
편집: James Tursa
2015년 4월 20일
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
카테고리
도움말 센터 및 File Exchange에서 Arithmetic Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!