about fprintf.

2 visualizaciones (últimos 30 días)
Ejay Kasai
Ejay Kasai el 13 de Sept. de 2011
hello, i would like to know how to display my final answer with sq. units. for example my area=4/3. i would like to know how to use fprintf so my final answer would become 4/3 sq. units. thank you!
  2 comentarios
Fangjun Jiang
Fangjun Jiang el 13 de Sept. de 2011
Are you asking to display a=4/3 as ratio of 4/3 instead of a=1.333, or are you asking to display whatever the square units? Do you want to display at command window, or to a file?
Jan
Jan el 13 de Sept. de 2011
What exactly are "sq. units"?

Iniciar sesión para comentar.

Respuesta aceptada

Jan
Jan el 13 de Sept. de 2011
Perhaps you wnat something like this:
x = 1.333333333333;
[a, b] = rat(x);
fprintf('%d/%d m^2\n', a, b)
  2 comentarios
Ejay Kasai
Ejay Kasai el 14 de Sept. de 2011
but how do display it in decimal places?
Jan
Jan el 14 de Sept. de 2011
fprintf('%f m^2\n', x)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by