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
Giorgos Papakonstantinou 2013년 8월 12일
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
Giorgos Papakonstantinou 2013년 8월 13일
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