Spline coordinates from spap2

6 views (last 30 days)
Biraj Khanal
Biraj Khanal on 29 Jun 2022
Edited: Torsten on 1 Jul 2022
I am trying to get third order spline approximation for a given set of points.
p=[..;..];
spline=spap2(knots,3,p(1,:),p(2,:));
This works and I can use fnplt to plot the curve. Howver, I am not sure how I can get the orthogonal coordinates.
For cscvn, fnval would return a 2D matrix of coordinates. However, it does not work here. Is there any solution to this?
  4 Comments
Torsten
Torsten on 29 Jun 2022
Edited: Torsten on 29 Jun 2022
You mean the spline coefficients in the different intervals ?
Maybe you can give an example with cscvn of what you want to get.
Biraj Khanal
Biraj Khanal on 29 Jun 2022
okay. i might be getting the terms wrong. but here is what i mean with cscvn.
p=[..;..];
c=cscvn(p);
p_new=fnval(c,linspace(c.breaks(1),c.breaks(end),50));
Here, p_new would be a 2D matrix which I can use to plot and get the similar curve as p.
My idea is to use spap2 to matrix like p and get a p_new with the specific number of points ( which is from the knots as I understand) . Say P is a 2X500 matrix. I am trying to get the approximate curve with the a lower number of points using the approximation.

Sign in to comment.

Accepted Answer

Torsten
Torsten on 29 Jun 2022
Edited: Torsten on 29 Jun 2022
x = -2:.2:2;
y=-1:.25:1;
[xx, yy] = ndgrid(x,y);
z = exp(-(xx.^2+yy.^2));
sp = spap2({augknt([-2:2],3),2},[3 4],{x,y},z);
xyq = [1.8;0];
value = fnval(sp,xyq)
value = 0.0178
exp(-xyq.'*xyq)
ans = 0.0392
  2 Comments
Biraj Khanal
Biraj Khanal on 1 Jul 2022
Edited: Biraj Khanal on 1 Jul 2022
I understand your solution. Here is what I was trying to do:
p = [..;..];
p1=spap2(40,3,p(1,:),p(2,:)); %for 40 knots and third order approximation
x=p1.knots.
y=fnval(p1,p1.knots)
p_approx = [x;y];
I just wanted to get p_approx for further steps. But, can you help me understand what the coefficients are in the structure?
Torsten
Torsten on 1 Jul 2022
Edited: Torsten on 1 Jul 2022
p1.coefs
give you the coefficients of the B-spline. My guess is that these are the coefficients a_ij in the representation of the spline
s(x,y) = sum_i sum_j a_ij * B_i(x) * B_j(y)
But you should read the documentation if this is correct.

Sign in to comment.

More Answers (0)

Categories

Find more on Spline Postprocessing in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!