MATLAB: How to indent the output of display() and disp()

displayindentationMATLABrepl

I am writing a small snippet to display trees of objects hierarchically.
I want to use standard Matlab functions as much as possible, therefore, I want to use disp() to display at least everything I don't care about implementing display() myself.
Is it possible to add, say, 10 spaces on the left of the output produced by disp(a)?
so that instead of:
>> a = 5
a =
5
I had
>> a = 5
a =
5

Best Answer

You can evalc() the disp to get aa character vector with newlines in it. you can modify that to add the required number of spaces and then display the results