Filter löschen
Filter löschen

angular data spline interpolation

5 Ansichten (letzte 30 Tage)
mukesh bisht
mukesh bisht am 22 Aug. 2021
Kommentiert: darova am 23 Aug. 2021
Hi, I have the following query using spline interpolation for angular data. The code attached below is from matlab documentation:
x = pi*[0:.5:2];
y = [0 1 0 -1 0 1 0;
1 0 1 0 -1 0 1];
pp = spline(x,y);
yy = ppval(pp, linspace(0,2*pi,101));
plot(yy(1,:),yy(2,:),'-b',y(1,2:5),y(2,2:5),'or')
axis equal
This code gives the closed piecewise polynomial for circle of radius 1unit. Now if I calculate the value of plynomial for a given query point, it doesnt give me the correct answer. why??
For ex: xq = 0; yq = ppval(pp,xq);
It gives yq = [1;0] but it should be yq = [1,-1];
  1 Kommentar
Julius Muschaweck
Julius Muschaweck am 23 Aug. 2021
If you think my answer is correct, please make it the "accepted answer".Thanks

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Julius Muschaweck
Julius Muschaweck am 22 Aug. 2021
Your x has five values, your y has seven values. This is a mismatch.
I think you should use
y = [0 1 0 -1 0;
1 0 -1 0 1];
and when you do that,
xq = 0; yq = ppval(pp,xq);
gives you [0;1] as it should. Your "circle" looks more triangular, but that's ok since the sine is badly approximated by the spline with only 5 support points.
  6 Kommentare
mukesh bisht
mukesh bisht am 22 Aug. 2021
ok. Thanks. I got it
darova
darova am 23 Aug. 2021

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by