Printing to screen with fprintf. Reclaim back the printed result after clearing the screen.

19 visualizaciones (últimos 30 días)
Suppose I use the fprintf as follows:
name='John';
height=1.8;
age=27;
fprintf('Name.............%s\n\n', name);
fprintf('Height...........%.2f m\n',height);
fprintf('Age..............%d \n',age);
Is there any way to reclaim the printed result after clearing the screen with:
clc
  3 comentarios
Cedric
Cedric el 12 de Ag. de 2013
Type
doc diary
in the command window. However, why would you reclaim printed results? The diary is usually used as a logging mechanism I would say, and not for reclaiming previous output to command window on a regular basis. What we need in general is keeping data, which are not erased when you execute CLC.
Giorgos Papakonstantinou
Giorgos Papakonstantinou el 12 de Ag. de 2013
Well If the printed results have the form of a report I find it useful to print the results whenever you want. In my case I have a function inside which I use fprint to build a "report". So when I call this function apart from the computational part it also makes report that is printed in the command window.
If find it useful if I can reclaim the printed results after clearing the screen, provided that the data still exist in the workspace

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Ag. de 2013
The results of fprintf() to the screen do not exist in the workspace, and are not obtainable through normal graphics routines.
However, I have not researched the advanced editor and command line capabilities that were added a couple of releases ago, so I hesitate to give a blanket "no". Maybe there would be a way to request a copy of what is in the command window just before you issue the clc(), and then re-output it after you issue the clc(). I'd be relatively sure you could not have this happen automatically whenever a clc() was issued (not without overriding the normal clc)
  2 comentarios
Giorgos Papakonstantinou
Giorgos Papakonstantinou el 13 de Ag. de 2013
I was also wondering if there is a compromising solution. Maybe if I print to text file.Then viewing the file from within the command line. Can this be implemented?
Walter Roberson
Walter Roberson el 13 de Ag. de 2013
Yes, you could probably build a function for that. You might also want to consider writing the output to a scrollable GUI element such as uicontrol('style', 'edit', 'enable', 'disable') (notice that is not 'enable', 'off')

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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