Print first few lines of output

21 views (last 30 days)
Suppose I do
summary(T)
Then it will print out statistics of all the variables in the table, which is good. But at the same time it will output all the information and will create "auto-scroll" that is very cumbersome. Thus I want to print out the first five lines of the output.
head(summary(T),5)
does not work.

Accepted Answer

Walter Roberson
Walter Roberson on 23 Jan 2021
Edited: Walter Roberson on 23 Jan 2021
summary(T(:,1))
If summary() was just being used as an example, then
temp = regexp(evalc("Put The Command Here"), '\n', 'split');
fprintf('%s\n', temp{1:min(end,5)});
such as
temp = regexp(evalc("summary(T)"), '\n', 'split');
fprintf('%s\n', temp{1:min(end,5)});
You can build a function to do this for you.
  5 Comments
Walter Roberson
Walter Roberson on 24 Jan 2021
Note that the code was designed so that if an error message is the output of the command, then only the first N lines of the error message are output.
The code is designed so that you can assign the output of HEAD() to a variable, but that if you do not do so then it outputs to the display.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!