how can i using fprintf to write unit for a data?

2 vues (au cours des 30 derniers jours)
Le Dung
Le Dung le 24 Mai 2017
Commenté : Le Dung le 25 Mai 2017
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]');

Réponse acceptée

the cyclist
the cyclist le 24 Mai 2017
Modifié(e) : the cyclist le 24 Mai 2017
time_max=0.024;
fprintf('Gia tri thoi gian ung voi chuyen vi lon nhat: %7.3f [s]\n',time_max)

Plus de réponses (1)

Walter Roberson
Walter Roberson le 24 Mai 2017
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.

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by