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

19 次查看(过去 30 天)
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 个评论
Cedric
Cedric 2013-8-12
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
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

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2013-8-13
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 个评论
Giorgos Papakonstantinou
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 2013-8-13
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')

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Entering Commands 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by