Create legend including tex symbols and elements from float array

11 ビュー (過去 30 日間)
SuperMartingale
SuperMartingale 2015 年 8 月 22 日
編集済み: SuperMartingale 2021 年 5 月 18 日
Hi all
I have an array of floats
eps = [0.1 0.15 0.2 0.25 0.3];
and I would like to use it as input into my legend (replace the hardcoded numbers):
legend({'\epsilon = 0.10','\epsilon = 0.15','\epsilon = 0.20','\epsilon = 0.25','\epsilon = 0.30'},...
'Interpreter','tex','FontSize',5.5,'Location','NorthEast')
Highly appreciating any ideas!

採用された回答

Star Strider
Star Strider 2015 年 8 月 22 日
This works:
epsln = [0.1 0.15 0.2 0.25 0.3];
lgdstr = regexp(sprintf('\\epsilon = %.2f\n', epsln), '\n', 'split');
legend(lgdstr(1:end-1), 'Interpreter','tex','FontSize',5.5,'Location','NorthEast')
  2 件のコメント
SuperMartingale
SuperMartingale 2015 年 8 月 22 日
Thank you!!
Star Strider
Star Strider 2015 年 8 月 22 日
My pleasure!

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

その他の回答 (0 件)

カテゴリ

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