Both functions disp
and display
do not have return parameters and
display variable content into command window.
I would like to get the result of function call (displayed string) into a
variable instead of output into command window, something like this str = ToString( myStruct );
where input variable is a MATLAB struct!
I am aware that display result depends on available width of command window, it can be either wide or narrow.
In all modern programming languages it would be a obj.ToString()
method.
The disp() function displays exactly one value/variable to the screen. The disp() function always uses one or more lines of output -- i.e., it always generates a carriage return at the end of its output.
disp( X ) displays the value of variable X without printing the variable name. Another way to display a variable is to type its name, which displays a leading “ X = ” before the value. If a variable contains an empty array, disp returns without displaying anything.
toString = @(x) evalc('disp(x)')
Not pretty, but it should get the job done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With