Publish symbolic equation to Latex with latex(symbolic equation)
8 次查看(过去 30 天)
显示 更早的评论
How to publish a symbolic equation such as y(x) (see code below) to latex using the Matlab publisher? Or specifically is it possible to generate a dynamic commend or define that a string is interpreted as a latex expression by the publisher?
%% Demonstration %% % *Text* syms x y(x)=sin(x)/pi; latex(y) latex(y) %% % $latex(y)$
latex(y) prints the latex code for the equation y to the command window. I want to tell the matlab publisher that it shall interpret this as a Latex formated expression (which it is). Ideal would be a solution like latexpublisher(latex(y)).
Please note that i found several workarounds which are all unsuitable imo. I am using Matlab 2016b
1 个评论
回答(1 个)
Sonam Gupta
2017-4-19
I think that the functionality that you are looking for is same as what the text() command provides. It gives you an option to specify the Interpreter as Latex. Below code shows how you can use it:
syms x
y(x)=sin(x)/pi;
str = latex(y);
axis off
text(0.5, 0.5, ['$$' str '$$'], 'Interpreter','latex', 'FontSize',28, ...
'HorizontalAlignment','center', 'VerticalAlignment','middle')
For more information about the text command, you can refer to following documentation link:
Hope this helps!
2 个评论
Sonam Gupta
2017-4-21
As far as I know the ability to replace the variable name with its value from the workspace for latex equations is not there.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!