Fitting the curve on poyfitn model
4 ビュー (過去 30 日間)
古いコメントを表示
i have 3d data and i have created curve on the data using the polyfitn function. Once i have the polyfitn model how can i use polyvan to get my values to plot the curve. Here is the set of command i have use and the error i am getting using polyvaln function
load data.mat
X = data(:,1);
Y =data(:,2);
Z =data(:,3);
p= polyfitn([X,Y],Z,3);
s = 1:92;
polyvaln(p,s);
Error using polyvaln (line 39)
Size of indepvar array and this model are inconsistent.
1 件のコメント
John D'Errico
2018 年 1 月 1 日
Please stop asking the same question on the very same data. This is now at least the third time you have asked this question.
採用された回答
John D'Errico
2018 年 1 月 1 日
編集済み: John D'Errico
2018 年 1 月 1 日
I saw this data the last time you asked a question about it. NO YOU CANNOT USE POLYFITN. PERIOD. If you could have used polyfitn, I would have suggested it. this data is simply not usable to support a multivariate polynomial model.
Worse, as I said in my response to your last question, you have errors in the variables, thus noise in each of x, y, and z. That makes modeling more difficult too.
To be honest, I think use of polyfit itself is of limited utility from what I saw in your last question.
x = data(:,1);
y = data(:,3);
z = data(:,2);
K = z >= 2;
plot3(x(K),y(K),z(K),'o')
box on
grid on
view(76,6)
I would note that depending on how I rotate that data, it looks very different.
view(177,30)
In the first view, we see what looks like a curve. That was how you showed that data in your first question.
In the second figure, we see that the identical data is now apparently a small portion of a surface. It is not enough of a surface to fit a multivariate polynomial model to it. Nor would I ever recommend use of polyfitn there.
As well, see that since you have a SURFACE, the use of polyfit is also not appropriate. You cannot use polyfit to build a surface model.
2 件のコメント
Matt J
2018 年 1 月 1 日
編集済み: Matt J
2018 年 1 月 1 日
as I said in my response to your last question, you have errors in the variables, thus noise in each of x, y, and z.
In fact, there are no errors in z. The z data is just a perfectly consecutive sequence of integer indices. x and y are functions of z, though what the model should be seems an open question.
John D'Errico
2018 年 1 月 2 日
編集済み: John D'Errico
2018 年 1 月 2 日
There is no model that will suffice here though. A polynomial model is insane. It also makes no sense to fit y(z) and x(z) independently.
その他の回答 (1 件)
Matt J
2018 年 1 月 1 日
編集済み: Matt J
2018 年 1 月 1 日
I don't think you need polyfitn for what you are doing. It can be done simply enough with the regular polyfit,
load data.mat
idx=data(:,2)<150; data(idx,:)=[]; %discard bad data
X = data(:,1);
Y = data(:,2);
Z = data(:,3);
px = polyfit(Z,X,3);
py = polyfit(Z,Y,3);
s=1:92;
xFit=polyval(px,s);
yFit=polyval(py,s);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Smoothing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!