필터 지우기
필터 지우기

Can I get the best fit curve from the plot of many scattered points?

조회 수: 6 (최근 30일)
Pichawut Manopkawee
Pichawut Manopkawee 2016년 10월 25일
댓글: dpb 2016년 10월 26일
Hi guys,
Do you know how can I make a fit curve from the plot of scattered points?. I need a fitted line with equation.
PS. I also attached the plot as I told you above.
Thanks in advance
  댓글 수: 3
John D'Errico
John D'Errico 2016년 10월 25일
편집: John D'Errico 2016년 10월 25일
A fit to what? What shape do you expect? What model will you pose? Random numbers? Are you asking for something like a random distribution here? I suppose then you might decide to model this process as a (perhaps normal) distribution with a variance that depends on x.
Otherwise, the best fit to that data is, in my judgement, a constant. So just take the mean of your data in y. That is the least squares estimate of a constant function. Zero seems pretty close to me though.
Pichawut Manopkawee
Pichawut Manopkawee 2016년 10월 25일
Hi dpb, and John D'Errico,
I highly appreciate your help. The reason why I ask you guys is that the mean number must be pretty close to zero or small negative number, but I need to get the exact number on the Y-axis.
the shape that I expect is just a line fitted to the data. No specific model is required. The data plotted are not the random numbers. They are the relationship between the slope-area and the curvature of the DEM.
I can provide you the whole figure, but what I am interested is just the number lower than 1 on the x axis.

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

답변 (2개)

Yifan Men
Yifan Men 2016년 10월 25일
If you have the x and y data in the workspace, a quick way is to open the Curve Fitting App and set the x and y data. Then you will be able to choose the most common curve shape from the list and see which one best fits your data.

dpb
dpb 2016년 10월 25일
Well, given the followup response, it's pretty simple to estimate the coefficients of a line given any set of data--of course, the results are going be residuals that look essentially the same as the values: but, maybe that's the desired result.
Given you have the data as x, y, then
ix=(x<1); % indices of the under-one x data
b=polyfit(x(ix),y(ix),1); % coefficients of a line for above data
As John notes, if you want to force a zero-slope line, then the least-squares estimate of the slope and intercept is simply
b=[0 mean(y(ix)]);
To evaluate the fit,
yhat=polyval(b,x(ix));
You can, of course, compare the two sets of coefficients from the above two cases and see just how much variation there is between the LS fit overall and the zero-slope case.
  댓글 수: 1
dpb
dpb 2016년 10월 26일
Well, you commented "it didn't work for me" in unaccepting an answer which is rather pointless if you don't say what seems to be the problem you see.
It certainly does what you asked for; how well it represents the data was going to be marginal at best as we warned you going in...but, show the results and what you think isn't right...we don't have the data.

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

Community Treasure Hunt

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

Start Hunting!

Translated by