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?

 Akzeptierte Antwort

Paulo Silva
Paulo Silva am 6 Mai 2011

8 Stimmen

MyVariable=evalc('disp(MyThingToShow)')

2 Kommentare

Daniel Shub
Daniel Shub am 6 Mai 2011
Look at that, there is a use for eval (well evalc ...).
Paulo Silva
Paulo Silva am 6 Mai 2011
the spy function without arguments is better :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Jan
Jan am 28 Jul. 2021

4 Stimmen

Since Matlab R2021a:
str = formattedDisplayText(x)
Manish Vankudre
Manish Vankudre am 13 Mär. 2018

0 Stimmen

Can you please give an example an explain

Kategorien

Mehr zu Variables finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by