How to show a legend consisted of more than one variable

조회 수: 1 (최근 30일)
Mahdi
Mahdi 2016년 6월 30일
편집: José-Luis 2016년 6월 30일
Helle everyone,
I want to show some intervals of graph as text in the legend. For example: 'the graph is in intervals (2-4) and (6-8) and ... red'. How can show these unknown number (the number varies by every diffenrent input data)in legend?
I know the solution for a vector size (1,2) as following:
LEGEND=['the graph is in interval (' vector(1) '-' vector(2) ') red'];
set(plot name,{'DisplayName'},{LEGEND});
legend show;

답변 (1개)

José-Luis
José-Luis 2016년 6월 30일
Almost there
str = ['the graph is in interval (', num2str(vector(1)), '-', num2str(vector(2)), ') red'];
  댓글 수: 2
Mahdi
Mahdi 2016년 6월 30일
Hi Luis,
thanks a lot for your answer, but it doesn't work. Imagine that I want to show the following text (as a legend of graph): 'the graph is in intervals (2-4) and (6-8) red'
First of all I build the matrix vector (im my code) --> vector=[2 4;6 8]. If I apply your suggestion, it results in str='the graph is in interval (2-6) red'. However, I am looking for a command, which yields both intervals (rows of matrix) in the legend with a 'and' delimiter!
José-Luis
José-Luis 2016년 6월 30일
편집: José-Luis 2016년 6월 30일
bstr = ['the graph is in interval (', num2str(vector(1)), '-', ...
num2str(vector(3)), ') and (', num2str(vector(2)), '-', ...
num2str(vector(4)), ') red'];

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by