How to convert to latex display from a cell array?

8 次查看(过去 30 天)
Dear all:
I am having trouble to display Greek in latex form. I have a cell array contains the following:
index = [ {'alpha'};
{'sigmaL'};
{'beta'};
{'theta'};
{'rho_a'};
{'kappa_y'};
{'kappa_pi'};
{'var_eps_a'};
{'var_eps_r'}];
Each of the cell in cell array 'index' represents a variable name and I want to plot each in one figure by using subplot. In each of the subplot, I want to have a title as the name of the variable in latex form. I know I can manually do so by adding a slash to the string, for example:
title('\fontsize{20}\alpha')
But I want to assign the name directly by referring to the cell array 'index' rather than typing the name explicitly, since in some cases not all variables are needed and I want to build a automate way to plot the variable.
count = 1;
for i = 1:row
for j = 1:col
subplot(row,col,count);
h = plot(bar_x(count,:),bar_y(count,:),'r',...
likelihood_region_Xaxis(count,:),likelihood_region(count,:),'b');
set(h,'LineWidth',4); title({\index{count}},'FontSize',20);
count = count + 1;
end
end
This is what I have tried, but Matlab doesn't seem to like it...
Any comments and help is highly appreciated, and thanks for your time and effort in advance!
Best,
Ben

采纳的回答

Friedrich
Friedrich 2011-4-26
Hi Ben,
please try this
set(h,'LineWidth',4); title(['\',index{count}]) ,'FontSize',20);
instead of
set(h,'LineWidth',4); title({\index{count}},'FontSize',20);
Best regards,
Friedrich

更多回答(1 个)

Ben Wang
Ben Wang 2011-4-26
Thanks Friedrich, it works.
Cheers
Ben

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by