LaTex in an annotation

31 ビュー (過去 30 日間)
Ismail Ghafoor
Ismail Ghafoor 2019 年 1 月 24 日
回答済み: Star Strider 2019 年 1 月 24 日
I'm trying to insert a formula into an annotation on a graph, my code is
annotation('textbox','interpreter','latex','String',str,'FitBoxToText','on');
str={'(1) $$y= \frac{1}{(1+x)^2} = \sum_{k=1}^\inftyk(-x)^{k-1}$$',...
'(2) $$y= sin^2(x) = \sum_{k=1}^\infty(-1)^{k+1}\frac{2^{2k-1}x^{2k}}{(2k)!}$$'...
'(3) $$y=e^{-x^2} = \sum_{k=1}^\infty(-1)^k\frac{x^{2k}}{k!}$$'};
However, this doesn't seem to work, any help is greatly appreciated.

採用された回答

Star Strider
Star Strider 2019 年 1 月 24 日
Your ‘str’ variable must come before your annotation call.
You are missing curly braces in the ‘\infty’ argument.
Change the order of the statements, add the curly braces, and it works:
str={'(1) $$y= \frac{1}{(1+x)^2} = \sum_{k=1}^\infty{k(-x)}^{k-1}$$',...
'(2) $$y= sin^2(x) = \sum_{k=1}^\infty{(-1)}^{k+1}\frac{2^{2k-1}x^{2k}}{(2k)!}$$'...
'(3) $$y=e^{-x^2} = \sum_{k=1}^\infty{(-1)}^k\frac{x^{2k}}{k!}$$'};
annotation('textbox','interpreter','latex','String',str,'FitBoxToText','on');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by