Borrar filtros
Borrar filtros

Latex Interpreter MATLAB title underscores

119 visualizaciones (últimos 30 días)
Stelina
Stelina el 10 de Oct. de 2014
Comentada: Guillaume el 23 de Oct. de 2014
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

Respuesta aceptada

Guillaume
Guillaume el 10 de Oct. de 2014
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 comentarios
Stelina
Stelina el 23 de Oct. de 2014
Thanx Guillaume. Indeed it was just the bracket. This works fine title(['File: ' filename 'Stim electr: ' num2str(StimElectr(n))],'interpreter','none')
Guillaume
Guillaume el 23 de Oct. de 2014
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by