two functions with descriptions in one graph

조회 수: 1 (최근 30일)
danielle sisserman
danielle sisserman 2020년 11월 28일
답변: Walter Roberson 2020년 11월 28일
for this code:
% approximating f
plot(X_in.', U.');
xlabel('x');
ylabel('approximate f(x)');
legend_strs = compose('Approximate f with h=%.2d', h);
legend(legend_strs);
I get the followin graph (for two different axis steps h = [0.2, 0.025]):
What I want is to add another function to the same graph (true function f) and to add a description of the line in the above right section saying "true function f".
say that f = cos(2x)
how can I do this?
Thank you.
  댓글 수: 2
VBBV
VBBV 2020년 11월 28일
What is the equation of true function f ?
danielle sisserman
danielle sisserman 2020년 11월 28일
f = cos(2x)

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

채택된 답변

Walter Roberson
Walter Roberson 2020년 11월 28일
f = @(x) cos(2*x);
plot(X_in.', U.', X_in.', f(X_in.'));
xlabel('x');
ylabel('approximate f(x)');
legend_strs = [compose('Approximate f with h=%.2d', h), "true function f"];
legend(legend_strs);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by