How to display units with my answer?

38 vues (au cours des 30 derniers jours)
Holden Earl
Holden Earl le 22 Mar 2020
Commenté : Holden Earl le 22 Mar 2020
prompt = 'Enter mass in pounds:';
x = input(prompt);
y = x*0.4536;
disp (y);
This is my current script and i want to have the answer display with 'kg' next to the answer and i cant figure out how to do it.

Réponse acceptée

Elysi Cochin
Elysi Cochin le 22 Mar 2020
Modifié(e) : Elysi Cochin le 22 Mar 2020
fprintf('%g kg\n', y)
  1 commentaire
Holden Earl
Holden Earl le 22 Mar 2020
Thanks heaps!!

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by