How to plot two functions in one graph?

조회 수: 18 (최근 30일)
Bakhtiyar Gurbanov
Bakhtiyar Gurbanov 2016년 11월 7일
댓글: Scott 2022년 8월 28일
I need to plot a graph where I can see how two functions interact with each other. Let's say first function is y1=a1*(x1^n)+b1*(x1^(n-1))+...+z1 and y2=a2*(x2^n)+b2*(x2^(n-1))+..+z2
Basically, y1 is a function of x1 and y2 is a function of x2.
I know that x1+x2=c, and I need to show where they intersect (if so) by showing them on the same graph, where y1 is starting from the left side and y2 is starting from the right side of the graph. The x axis' length should be equal to d.
Thanks.

채택된 답변

Star Strider
Star Strider 2016년 11월 7일
Assuming that you have already evaluated ‘y1’ and ‘y2’ over the same (or similar) ranges of ‘x1’ and ‘x2’, the easiest way is to use the hold function:
figure(1)
plot(x1, y1)
hold on
plot(x2, y2)
hold off
grid
The grid call is optional but helpful.
  댓글 수: 2
Max Johnson
Max Johnson 2020년 3월 31일
I know this is 4 years later but you sir/maam are the real MVP
Scott
Scott 2022년 8월 28일
baller

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by