フィルターのクリア

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 Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by