Use Legend to show array and matrix
古いコメントを表示
I have one array and one matrix like A={'x' 'y' 'z'}; B=[1 2 3]. I want to make a legend as: x=1 y=2 z=3
in my plot, could anyone help me with this issue.
Thanks
採用された回答
その他の回答 (1 件)
Honglei Chen
2013 年 12 月 16 日
You can do this:
plot(rand(10,3))
legend(cellfun(@(x,y)sprintf('%s=%s',x,y),A,B,'UniformOutput',false))
8 件のコメント
Wei
2013 年 12 月 16 日
Azzi Abdelmalek
2013 年 12 月 16 日
Why have you changed your question?
Wei
2013 年 12 月 16 日
Honglei Chen
2013 年 12 月 16 日
Your B now contains numbers, replace the second %s in my code to %d if they are integers
Wei
2013 年 12 月 16 日
Honglei Chen
2013 年 12 月 17 日
You change the second one to a regular array, you can use Walter's code below
Wei
2013 年 12 月 17 日
Wei
2013 年 12 月 17 日
カテゴリ
ヘルプ センター および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!