Issue with sprintf () latex interpreter

조회 수: 121 (최근 30일)
Turbulence Analysis
Turbulence Analysis 2022년 4월 27일
댓글: Turbulence Analysis 2022년 4월 28일
In the below command, in the place of X=1, is it posiible to call the value that's been defined outside. I tried to use sprintf(), but was not successful.
a = 1;
text(20,2620,{'$[\alpha_{X=1]$'},'FontSize',28,'Color','b','Interpreter','latex');
text(20,2620,sprintf{'$[\alpha_{X='%3dmm',a}]$'},'FontSize',28,'Color','b','Interpreter','latex');

채택된 답변

Steven Lord
Steven Lord 2022년 4월 27일
a = 1;
disp('Here''s how to include a single quote in a char vector')
Here's how to include a single quote in a char vector
disp("Here's how to include a single quote in a string array")
Here's how to include a single quote in a string array
fprintf("To include %c in the output of fprintf or sprintf, escape it: \\", '\')
To include \ in the output of fprintf or sprintf, escape it: \
text(0.5,0.25,sprintf('$[\\alpha_{X=''%3dmm''}]$', a),'FontSize',28,'Color','b','Interpreter','latex');
text(0.5,0.75,sprintf("$[\\alpha_{X='%3dmm'}]$",a),'FontSize',28,'Color','b','Interpreter','latex');
  댓글 수: 2
Turbulence Analysis
Turbulence Analysis 2022년 4월 28일
Thanks, Steven!!
Is it possible to remove the quote, I mean instead of X = '1mm' just like this X = 1mm
Turbulence Analysis
Turbulence Analysis 2022년 4월 28일
Sorry, I used as below.. Its okay now
text(0.5,0.75,sprintf("$[\\alpha_{X= %3dmm}]$",a),'FontSize',28,'Color','b','Interpreter','latex');

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by