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

27 views (last 30 days)
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 Comments
Cedric
Cedric on 12 Aug 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 on 12 Aug 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

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 13 Aug 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 Comments
Giorgos Papakonstantinou
Giorgos Papakonstantinou on 13 Aug 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 on 13 Aug 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')

Sign in to comment.

More Answers (0)

Categories

Find more on Entering Commands in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!