Save disp output as a string/cell variable

The command disp(x) does a reasonable job of displaying variables of any class. For example, it expands structures to show their fields and values. Is it possible to capture this formatted output as a variable?

 Accepted Answer

MyVariable=evalc('disp(MyThingToShow)')

2 Comments

Look at that, there is a use for eval (well evalc ...).
the spy function without arguments is better :)

Sign in to comment.

More Answers (2)

Since Matlab R2021a:
str = formattedDisplayText(x)
Can you please give an example an explain

Categories

Asked:

on 6 May 2011

Answered:

Jan
on 28 Jul 2021

Community Treasure Hunt

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

Start Hunting!