how can i using fprintf to write unit for a data?
4 次查看(过去 30 天)
显示 更早的评论
Hi, now i trying to use fprintf to write a sentence. i want to Matlab return as below: "Max value of time is: 0.024 [s] " And i use code (below). But i can't do it. Can somebody help me? Thank you so much! My code:
time_max=0.024;
fprintf('Gia tri thoi gian ung voi chuyen vi lon nhat: %d \n',time_max,'[s]');
0 个评论
采纳的回答
the cyclist
2017-5-24
编辑:the cyclist
2017-5-24
time_max=0.024;
fprintf('Gia tri thoi gian ung voi chuyen vi lon nhat: %7.3f [s]\n',time_max)
更多回答(1 个)
Walter Roberson
2017-5-24
time_max=0.024;
fprintf('Gia tri thoi gian ung voi chuyen vi lon nhat: %g %s\n',time_max,'[s]');
Note the change from %d to %g as your data is not integer.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!