Tuesday, August 24, 2010

Tex on matlab figure axis labels

It is highly desirable to have tex characters into matlab figures. It is not one to one. But works!
The following is very good resource:
http://www.mathworks.com/access/helpdesk/help/techdoc/creating_plots/f0-4741.html


xlabel(Number of Samples (\textit{N}))
??? xlabel(Number of Samples (\textit{N}))
                  |
Error: Unexpected MATLAB expression.

>> xlabel(Number of Samples (textit{N}))
??? xlabel(Number of Samples (textit{N}))
                  |
Error: Unexpected MATLAB expression.

>> xlabel(Number of Samples (N))
??? xlabel(Number of Samples (N))
                  |
Error: Unexpected MATLAB expression.

>> xlabel('Number of Samples (textit{N})')
>> xlabel('Number of Samples (\textit{N})')
Warning: Unable to interpret TeX string
"\textit{N})"
>> xlabel('Number of Samples ('\textit{N},')')
??? Undefined function or variable 'N'.

>> xlabel('Number of Samples ('\textit{'N'},')')
??? Undefined variable "textit" or class
"textit".


>> xlabel('Number of Samples {\it{N}')
Warning: incomplete command in TeX text
string:
'Number of Samples {\it{N}'
>> xlabel('Number of Samples {\itN}')
Worked!