필터 지우기
필터 지우기

Latex Interpreter MATLAB title underscores

조회 수: 119 (최근 30일)
Stelina
Stelina 2014년 10월 10일
댓글: Guillaume 2014년 10월 23일
Hi there,
I was using this title command as the title of the plot: title(['File:' filename 'Stim electr: 'num2str(StimElectr(n))])
The filename contains underscores that are interpreted as subscripts in my MATLAB 2013b. Turning off the LaTEX interpreter locally seems to work only when I do not include the strings 'File:' and 'Stim electr' in my title command.
In other words, this works fine: title(filename,'interpreter','none') and underscores are kept as they are, but this doesn't: title(['File:' filename, 'interpreter', 'none']).
How can I keep the underscores for my initial title command?? (back slash etc I cannot use coz I cannot change the filename manually each time)
Thanx a lot!! Stelina

채택된 답변

Guillaume
Guillaume 2014년 10월 10일
It looks like you misplaced the closing bracket. The proper command should have been:
title(['File:' filename], 'interpreter', 'none');
As it was you just included your 'interpreter', 'none' instruction in the title of the figure. I would recommend you use sprintf instead of concatenating strings. It makes the intent much clearer and may have helped avoid such error:
title(sprintf('File:%s', filename), 'interpreter', 'none');
  댓글 수: 2
Stelina
Stelina 2014년 10월 23일
Thanx Guillaume. Indeed it was just the bracket. This works fine title(['File: ' filename 'Stim electr: ' num2str(StimElectr(n))],'interpreter','none')
Guillaume
Guillaume 2014년 10월 23일
Again, I would recommend sprintf for that:
title(sprintf('File: %s Stim electr: %f', filename, StimElectr(n)), 'interpreter', 'none');
I find this much easier to read.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by