Borrar filtros
Borrar filtros

How can I determine the the X and Y equation using coefficients of cscvn function?

5 visualizaciones (últimos 30 días)
Ashkan Rigi
Ashkan Rigi el 24 de Feb. de 2022
Comentada: Hesam el 14 de Jun. de 2024 a las 13:51
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?

Respuestas (1)

John D'Errico
John D'Errico el 24 de Feb. de 2022
Editada: John D'Errico el 24 de Feb. de 2022
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)
S = struct with fields:
form: 'pp' breaks: [0 0.4721 1.8541 3.2393 4.7461 5.9336 6.8685 7.9242 9.4046 10.9559] coefs: [18×4 double] pieces: 9 order: 4 dim: 2
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)
xypred = 2×1
-0.1122 -0.8774
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.
hold on
xlabel 'X'
ylabel 'Y'
  1 comentario
Hesam el 14 de Jun. de 2024 a las 13:51
Hi, can you help me to how I can find control points of an arbitrary curve? cscvn does not give me expliciteley

Iniciar sesión para comentar.


Más información sobre Splines en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by