How can I determine the the X and Y equation using coefficients of cscvn function?
4 次查看(过去 30 天)
显示 更早的评论
Hello every body. As you know matlab cscvn does 2D interpolation or parametric interpolation. How can I get the equation of X and Y using coefficients of cscvn? As another quaestion how can I do 2D parametric interpolation?
0 个评论
回答(1 个)
John D'Errico
2022-2-24
编辑:John D'Errico
2022-2-24
Congratulations! You are the 1 millionth person to ask essentially the same question. Your reward for this is a one-way un-paid trip to the place of your desire. Of course, you need to pay for the trip, and make all arrangements yourself. Hey, have a nice bottle of champaigne when you get there, again paid for out of your own wallet. Feel free to also arrange for the return trip, of course, but if you want to go there so badly, then why would you return?
Seriously, in the case of any spline function, there is no simple form. (And yes, this same question seems to get asked over and over again, hence my response.) Instead, what you would have are a long list of cubic polynomial segments, distinct between each and every pair of break points. Yes, you could extract them, but it is hardly worth the effort, since there will be as many such cubic segments as there are intervals between pairs of points to be interpolated.
In the worse case of cscvn, it gets a bit more complicated, since cscvn is a parametric interpolant. There is NO function of the form y(x) that you can generate, even if you consider this as a list of distinct piecewise polynomial segments. This is because cscvn models x and y separately. So you have essentially x(t) and y(t), where t is an internal parameter, defined in terms of the arc length along the linear chords between pairs of points. Then each of x(t) and y(t) are themselves now cubic splines, and it becomes impossible to write a function of the form you seem to want.
In general, how can you do 2-d parametric interpolation? I'm not sure what you are asking. The simple answer is to use cscvn, and let it do the work. Or you can use my interparc, a tool posted on the file exchange. But it also will stubbornly not provide any functional form, because for any fully general set of points, there is no trivial solution.
XY = randn(2,10);
S = cscvn(XY)
It is just a spline. Nothing easy to look at. But easy to use. You can evalaute the curve at any point between the list of breaks and get a prediction.
xypred = fnval(S,5.5)
So an (x,y) pair. If your goal is to find y, as a function of x, that would be difficult, since the curve is often a multi-valued one. Could you do it? Well, yes. Technically I could probably write some code that would extract all solutions y, for any given value of x. I won't. But I certainly could.
fnplt(S)
hold on
plot(XY(1,:),XY(2,:),'ro')
plot(xypred(1),xypred(2),'gs')
xlabel 'X'
ylabel 'Y'
1 个评论
Hesam
2024-6-14
Hi, can you help me to how I can find control points of an arbitrary curve? cscvn does not give me expliciteley
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Splines 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!