Hello, I am trying to output the name of an image file I onto a figure that shows the picture. The name is obtained from and checks out OK in the matlab window.
out2 =
NoSerialNumber_R03C02_3-Swath1_C5_T05_red.tif.
However, it appears on the figure weird
Im assuming its to do with the underscores - how can I correct it? Thanks

 채택된 답변

Oleg Komarov
Oleg Komarov 2014년 9월 18일
편집: Oleg Komarov 2014년 9월 18일

0 개 추천

By default the interpreter of text objects is set to 'tex'. Set it to 'none', i.e.
set(obj,'Interpreter','none')
For reference, check the text property Interpreter.

댓글 수: 5

Thanks, I tried this and got the following:
Undefined function or variable 'obj'.
Oleg Komarov
Oleg Komarov 2014년 9월 18일
편집: Oleg Komarov 2014년 9월 18일
Of course! obj is a generic way to say handle to your object. You didn't post any lines of code. How am I supposed to know what you're doing :) Therefore, my answer is a generic one that you need to adapt either by setting the properties when creating that text object, or after by setting it's property with set().
Im sorry. I just create a figure f and text to it.
figure(f);
movegui(f,'center');
out1=folder;
text(2,-95,out1, 'color', 'b','FontSize',6);
I've found a way anyway:
set(0,'DefaultTextInterpreter','none');
Thnaks for your help. Jason
Oleg Komarov
Oleg Komarov 2014년 9월 18일
편집: Oleg Komarov 2014년 9월 18일
Be careful when setting the defaults. It's easy to forget that did it for all cases when 'Interpreter' is a valid property. It's better to call it explicitly for the specific object.
You can use the properties directly with text():
text(2,-95,out1, 'color', 'b','FontSize',6, 'Interpreter','none');
Jason
Jason 2014년 9월 18일
Thankyou, thats perfect.

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

추가 답변 (1개)

Ilham Hardy
Ilham Hardy 2014년 9월 18일

0 개 추천

Without adjusting your interpreter setting (keep LaTeX interpreter on), you can use backslash just before the underscore to keep the underscore as underscore and not TeX command of subscript:
e.g.
title(NoSerialNumber\_R03C02\_3-Swath1_C5\_T05\_red.tif)

댓글 수: 1

Jason
Jason 2014년 9월 18일
thanks for the advice, but each file I ready in has a different name so it sno possible for me to manually go and change the text to include an additional backslash.

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

카테고리

도움말 센터 및 File Exchange에서 Language Support에 대해 자세히 알아보기

질문:

2014년 9월 18일

댓글:

2014년 9월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by