How to remove zeros from double value?
7 次查看(过去 30 天)
显示 更早的评论
hi every one
I have a set D that contains values in double?
D=0.2352, 0.5263
I want to display
D= 0.23, 0.52
Thak you
3 个评论
回答(2 个)
Walter Roberson
2022-12-18
D = [0.2352, 0.5263];
d = floor(D*100)/100;
%version 1
fprintf('D = '); fprintf('%.2f, ', d(1:end-1)); fprintf('%.2f\n', d(end)); %must be one line for LiveScript
%version 2
disp("D = " + strjoin(compose("%.2f", d), ', '))
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!