MATLAB: Latex Interpreter MATLAB title underscores

latex interpreterunderscores

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

Best Answer

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');