How to display the value of a function?

67 visualizaciones (últimos 30 días)
Hdez
Hdez el 10 de Nov. de 2020
Respondida: Star Strider el 10 de Nov. de 2020
Hello everyone, I want to display the value of At on the command window, but not only the value but I want to see At= the result of the function. It is sommething insignificant but I am struggling
At= 0.25*h^2/alpha

Respuestas (2)

Walter Roberson
Walter Roberson el 10 de Nov. de 2020
h = rand()*20;
alpha = rand();
At = 0.25*h.^2./alpha;
disp(At); %will not include the "At = "
65.1895
display(At); %will include the "At ="
At = 65.1895
At %no semi-colon! Will include the "At = "
At = 65.1895

Star Strider
Star Strider el 10 de Nov. de 2020
I am not exactly certain what you want.
Try this:
h = 42;
alpha = pi;
At = 0.25*h^2/alpha;
fprintf('\n%.2f = 0.25 * %.2f^2/%.2f\n', At, h, alpha)
producing:
140.37 = 0.25 * 42.00^2/3.14
.

Categorías

Más información sobre Programming 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