scientific notation
조회 수: 15 (최근 30일)
이전 댓글 표시
i dont know why but matlab is printing out my y values in scientific notation which i do not want, how do i do that?
disp('table of degrees to radians')
disp(' degrees radians')
for i=0:1:36
x=5*i;
y=x*pi/180;
fprintf('\n %i %i',x,y);
end
댓글 수: 0
채택된 답변
추가 답변 (2개)
the cyclist
2011년 8월 1일
disp('table of degrees to radians')
disp(' degrees radians')
for i=0:1:36
x=5*i;
y=x*pi/180;
fprintf('\n %i %f',x,y); % Changed to %f
end
댓글 수: 1
Jan
2011년 8월 1일
The %i format displays integer values as integers, but for fractional parts the scientific notation is used. If I understand you correctly, you want to display integer values for a non-integer DOUBLE:
for i=0:1:36
x = 5*i;
y = x*pi/180;
fprintf('\n %i %.0f', x, y);
% or: fprintf('\n %i %i', x, round(y));
end
See also: FLOOR, FIX.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!