필터 지우기
필터 지우기

Align text in two lines with respect to a location

조회 수: 4 (최근 30일)
Kyle Wang
Kyle Wang 2015년 4월 1일
댓글: Kyle Wang 2015년 4월 16일
Say, I have two strings 'a = 2' and 'bbb = 641', now I display them in a column using the command
display(['a = 2', char(10), 'bbb = 641'] )
it looks like
a = 2
bbb = 641
how can I align them with respect to '=':
a = 2
bbb = 641

채택된 답변

dpb
dpb 2015년 4월 1일
편집: dpb 2015년 4월 1일
Use specific format string if you want a specific format...
>> fprintf('%8s = %4d\n','a',2, 'bbb',641)
a = 2
bbb = 641
>>
"More than likely you're using proportional fonts..."
The default is Helvetica. To see the issue, try
hT=text(0.4,0.2,{sprintf('%8s = %4d\n','a',2, 'bbb',641)});
for i=1:4
pause(0.75),set(hT,'fontname','Courier')
pause(0.75),set(hT,'fontname','Helvetica')
end
>>
  댓글 수: 5
dpb
dpb 2015년 4월 1일
More than likely you're using proportional fonts...
Kyle Wang
Kyle Wang 2015년 4월 16일
Very good answer, thanks, dpb!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by