Need help debugging an error with Latex Interpreter and sprintf

For some reason I keep getting errors with the interpreter when I try to put in this code:
title(sprintf('Pressure $(1-M_\infty^2)u_{xx}+u_{yy}=0$, $M_\infty=%s$', Minf),'Interpreter','latex')
Anyone have suggestions for the formatting?

 採用された回答

Star Strider
Star Strider 2017 年 12 月 3 日

2 投票

You need to use two consecutive \\ in fprintf and sprintf.
This works:
title(sprintf('Pressure $(1-M_\\infty^2)u_{xx}+u_{yy}=0$, $M_\\infty=%s$', Minf),'Interpreter','latex')

3 件のコメント

Dahlia Pham
Dahlia Pham 2017 年 12 月 3 日
Ah, noted. Thanks a bunch!
Star Strider
Star Strider 2017 年 12 月 3 日
As always, my pleasure.
Muhammad Sajid Haroon
Muhammad Sajid Haroon 2021 年 6 月 23 日
it works, great

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by