Save disp output as a string/cell variable

42 views (last 30 days)
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

Paulo Silva
Paulo Silva on 6 May 2011
MyVariable=evalc('disp(MyThingToShow)')
  2 Comments
Daniel Shub
Daniel Shub on 6 May 2011
Look at that, there is a use for eval (well evalc ...).
Paulo Silva
Paulo Silva on 6 May 2011
the spy function without arguments is better :)

Sign in to comment.

More Answers (2)

Jan
Jan on 28 Jul 2021
Since Matlab R2021a:
str = formattedDisplayText(x)

Manish Vankudre
Manish Vankudre on 13 Mar 2018
Can you please give an example an explain

Categories

Find more on Performance and Memory 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!