Tab disappears in formatted string in multiline text command

조회 수: 3 (최근 30일)
KAE
KAE 2021년 1월 13일
댓글: Jan 2021년 1월 13일
I would like to label a plot with a multiline formatted string which includes some tabs, but the tabs disappear on the plot. How to fix this? (I don't want to substitute spaces for the tabs since I am lining up colums in my real plot label).
Here's an example,
% Make example plot
f1 = figure;
peaks;
view(2);
shading flat;
hold on;
% Create the string to label it with
str = sprintf('%6.4f\t\t%6.4f\nbbbbbbbbbbbbbb\nccccccccccc', rand(2,1));
disp(str) % Tabs are present
% Label the plot with string
t = text(-3, 0.4, str); % The text is labeled but the tabs have disappeared

채택된 답변

WalterWhite
WalterWhite 2021년 1월 13일
t = text(-3, 0.4, detab(str));
  댓글 수: 2
KAE
KAE 2021년 1월 13일
편집: KAE 2021년 1월 13일
Embarrasingly, I asked the same thing earlier. However now I am having trouble with detab in R2020a.
detab(str)
DETAB> file not found <>
ans =
[]
The comments in detab say the input should be a cell or a file. I will check into this.
Jan
Jan 2021년 1월 13일
@KAE: This is the documented behavior of this function: if the input is a CHAR vector, it is used as file name. Provide a cell string instead:
detab({str})

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by