Save disp output as a string/cell variable

17 vues (au cours des 30 derniers jours)
Daniel Shub
Daniel Shub le 6 Mai 2011
Réponse apportée : Jan le 28 Juil 2021
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?

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (2)

Jan
Jan le 28 Juil 2021
Since Matlab R2021a:
str = formattedDisplayText(x)

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

Catégories

En savoir plus sur Variables dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by