Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Is it possible to create a legend on a graph which is reliant on the function input?

조회 수: 1 (최근 30일)
Alok Virkar
Alok Virkar 2017년 11월 3일
마감: MATLAB Answer Bot 2021년 8월 20일
I am graphing a function, and I want the legend on the graph to post what the input of the function is...

답변 (2개)

KSSV
KSSV 2017년 11월 3일
x = linspace(0,2*pi) ;
f1 = @(x) sin(x) ;
f2 = @(x) x.^2 ;
y1 = f1(x) ;
y2 = f2(x) ;
figure
hold on
plot(x,y1,'r')
plot(x,y2,'b')
legend('sin(x)','x^2')

Walter Roberson
Walter Roberson 2017년 11월 3일
Yes but it would not often be readable.
For a function with input in the variable x you can do
legend( num2str(x))
However the user could just look at the plot to see what the range of the values were?

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by