how to write equation in legend correctly in latex

54 ビュー (過去 30 日間)
Dharma Khatiwada
Dharma Khatiwada 2022 年 3 月 6 日
編集済み: Scott MacKenzie 2022 年 3 月 6 日
I am trying to write following legend using latex interpreter but I keep getting this error:
"String scalar or character vector must have valid interpreter syntax"
This is my legend information. 'a' is just a number defined in the script. Suggestions will be highly appreciated.
legend(['$t_{1}=t_{2}± $' num2str(a*100)])

回答 (1 件)

Scott MacKenzie
Scott MacKenzie 2022 年 3 月 6 日
編集済み: Scott MacKenzie 2022 年 3 月 6 日
MATLAB by default uses a subset of TeX. That's probably all you need:
% test data
legend(['t_{1}=t_{2}±' num2str(a*100)]);


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

Community Treasure Hunt

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

Start Hunting!

Translated by