Polyfit plot just need one line

조회 수: 1 (최근 30일)
Dennis
Dennis 2022년 10월 11일
댓글: Dennis 2022년 10월 12일
The following code generates me this plot:
[p,S] = polyfit(x,y,4);
alpha=0.05;
[y_fit,delta] = polyconf(p,x,S,'alpha',alpha);
% [y_fit,delta] = polyval(p,x,S);
plot(x,y_fit,'r-');
plot(x,y_fit-delta,'m--',x,y_fit+delta,'m--');
However i just want one line to be plotted and not a thousand...
Can somebody tell me how to do that?

채택된 답변

dpb
dpb 2022년 10월 11일
That looks like your data are just a scatter all over and you're asking polyconf to evaluate the fit and the intervals over all data points, then plotting all those results.
When you do that, it evaluates the points in the order in which they exist in the raw data vectors and draws point-to-point in that order.
You forgot to attach the data so we can't reproduce,but try
[x,ix]=sort(x);
y=y(ix);
before calling polyconf and see if doesn't work out better
  댓글 수: 1
Dennis
Dennis 2022년 10월 12일
thank you it worked!

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by