Hi there,
I am trying to plot a line using the ployfit and command
x and y are the coordinates in attached xy the plot.
I can't plot a polyfit curve that reproduces the original.
I alway came up with something different from the original curve.

8 件のコメント

Star Strider
Star Strider 2019 年 12 月 5 日
Perhaps if you post your code, we can help you find and solve the problem.
dpb
dpb 2019 年 12 月 5 日
編集済み: dpb 2019 年 12 月 5 日
Well, there's absolutely no chance the figure was a polynomial that generated it....where did you get it from???
Is there any physical basis for the data that would give a klew as to what the underlying model should be?
Paul Rogers
Paul Rogers 2019 年 12 月 5 日
p1=polyfit(x,y,3);
x_intrest=[0:0.01:0.8];
y_intrest=polyval(p1,x_intrest);
plot(x_intrest,y_intrest)
Paul Rogers
Paul Rogers 2019 年 12 月 5 日
yes I got the y from a more complex equation, datas in y are the evalueted point I then wanted to approximated
Guillaume
Guillaume 2019 年 12 月 5 日
Polynomial fitting is not magical. If the function you want to fit is nothing like a polynomial, as you have here, there's no way you'll find a good fit.
You'll have to try another kind of fit as dpb said and to know what that fit is you need to know some details about what your data represent.
Image Analyst
Image Analyst 2019 年 12 月 5 日
Can you attach a screenshot? I can't open the .fig file directly from Firefox - it throws an error message when trying to launch MATLAB to display the figure even though MATLAB is already running.
dpb
dpb 2019 年 12 月 6 日
Here ya' go, IA...xy.jpg
dpb
dpb 2019 年 12 月 6 日
"I got the y from a more complex equation, ..."
Well, there's the place to start. What makes sense to approximate whatever that is/was.
What restrictions are on the approximation used, if any?

サインインしてコメントする。

 採用された回答

Paul Rogers
Paul Rogers 2019 年 12 月 6 日
編集済み: Paul Rogers 2019 年 12 月 6 日

0 投票

here we are, I think I found the solution.
I can select only a portion of that curve and take the x and y values,
then the code it's this
p1=polyfit(x,y,4);
t_intrest=[0.2:0.1:0.4];
y_intrested=polyval(p1,t_intrest);
plot(x,y);
hold on
plot(t_intrest,y_intrested);
hold on
In attaced the new x and y.
Now it's up to me to find the largest portion possible where I can use polyfit.

5 件のコメント

dpb
dpb 2019 年 12 月 6 日
"Now it's up to me to find the largest portion possible where I can use polyfit."
Why on earth is that so????
That section would fit a quadratic almost perfectly but still why not use a form that fits the data instead instead of trying to make it complicated?
>> N1=201;N2=401;
>> b=polyfit(x(N1:N2),y(N1:N2),2);
>> hL=plot(x(N1:N2),polyval(b,x(N1:N2)),'r-');
>> xlim([0.15 0.45])
>>
xy.jpg
Paul Rogers
Paul Rogers 2019 年 12 月 6 日
the thing is that I am trying to use the polyfunction for the larger portion possible of this curve
xy.jpeg
dpb
dpb 2019 年 12 月 6 日
That's just not feasible.
Guillaume
Guillaume 2019 年 12 月 6 日
I'm not sure how many times we can say it, your curve is nothing like a polynomial and attempting to fit a polynomial to it is the wrong approach.
To me it looks like your curve may be a log-normal curve. Again, some information on what created that curve could tell you that.
Paul Rogers
Paul Rogers 2019 年 12 月 6 日
編集済み: Paul Rogers 2019 年 12 月 6 日
I am trying to find a polynomial approx for that curve. I don't mean on its ooverall domain, it would be good even on a portion of that.
For example, I found that from 0 to 0.8 (more or less), it could be use this method.
P.S.
Thanks everyone for the help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

質問済み:

2019 年 12 月 5 日

編集済み:

2019 年 12 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by