How can I indent the output of display() and disp()?
조회 수: 25 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Walter Roberson
2018년 12월 10일
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
추가 답변 (2개)
KSSV
2018년 12월 10일
USe fprintf
a = 5 ;
fprintf(' %f\n',a)
댓글 수: 1
Walter Roberson
2018년 12월 10일
Trees of objects tends to suggest that the inputs are not necessarily numeric .
madhan ravi
2018년 12월 10일
Just use fprintf() or sprintf()
a=5;
fprintf(' a=\n')
fprintf(' %d\n',a)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!