필터 지우기
필터 지우기

How do I graph two trendlines on one graph?

조회 수: 8 (최근 30일)
Robert Fehr
Robert Fehr 2015년 3월 18일
댓글: Robert Fehr 2015년 3월 20일
I can plot two data sets on graph, however when I go to add a trend line, I can only do so for one data set. I need to be able two add a trend line for both data sets. So my plot will have to data sets and two trendlines.
Thanks guys,
Bobby
  댓글 수: 1
Michael Haderlein
Michael Haderlein 2015년 3월 18일
Are you referring to some special tool or just to normal plotting? In the first case, which tool? In the second case, why are you not able to plot two trendlines? Here, I use smooth() as trendline:
x=linspace(0,10);
y1=(x+rand(size(x))).^2;
y2=(10-x+rand(size(x))).^2;
figure, plot(x,y1,x,y2)
sy1=smooth(y1);
sy2=smooth(y2);
hold all
plot(x,sy1,'k',x,sy2,'k')
-> works.

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

채택된 답변

Pritesh Garg
Pritesh Garg 2015년 3월 18일
Try using the command hold on and plot the other trendline. (Type help hold on in the command window for description)
  댓글 수: 1
Robert Fehr
Robert Fehr 2015년 3월 20일
Thanks! I used this after creating to fits and it worked well.

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

추가 답변 (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