Borrar filtros
Borrar filtros

fprintf repeat

1 visualización (últimos 30 días)
Stephen
Stephen el 14 de Mzo. de 2012
Hey I'm trying to do something... and I don't know if it's possible :s
I'm currently drawing on subfunctions and showing the result via fprintf, however I want to simplify it if I can.
If my code has the following;
fprintf('My results are %.5f and %.5f' f(x), (f(x)/2))
Is there anyway to avoid having to state "f(x)" twice? I know I could define it earlier by something like "a = f(x)" and then have the fprintf have "a, a/2" but I want to keep as much of the code as I can in the fprintf.
Is there any way I can do this? I would assume not, but MATLAB has supprised me before!
I appretiate the help and if any more details are needed just ask :)

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 14 de Mzo. de 2012
fprintf('My results are %.5f and %.5f', f(x)./[1, 2])
Hey, it's not a better solution but it meets your requirements.
  3 comentarios
Sean de Wolski
Sean de Wolski el 14 de Mzo. de 2012
yup that's basically it!
Stephen
Stephen el 14 de Mzo. de 2012
Thank you very much for the help :) Much appretiated :D

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Import and Export en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by