How to keep decimal float point only

3 次查看(过去 30 天)
I could not find any answer about this. So I have a float number (a=323.153), I wanna output look like this with keeping decimal point only:
>> a=323.
What format shall I use?
Thanks.

采纳的回答

Robert U
Robert U 2021-2-3
If it is just for display you can specify the output format in fprintf.
a = 323.153;
fprintf('<< a = %.0f.\n',a)
output:
<< a = 323.
Kind regards,
Robert

更多回答(1 个)

Walter Roberson
Walter Roberson 2021-2-3
https://www.mathworks.com/help/matlab/ref/fix.html
  2 个评论
JZ
JZ 2021-2-3
Thanks, Walter.
It's not exactly what I need. I need output with a dot, so (>>a=323.).
Alex Alex
Alex Alex 2021-2-3
Convert to string format and add point manually?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

标签

产品


版本

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by