Spline coordinates from spap2

조회 수: 7 (최근 30일)
Biraj Khanal
Biraj Khanal 2022년 6월 29일
편집: Torsten 2022년 7월 1일
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
Torsten
Torsten 2022년 6월 29일
편집: Torsten 2022년 6월 29일
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 2022년 6월 29일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
Torsten 2022년 6월 29일
편집: Torsten 2022년 6월 29일
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
Biraj Khanal
Biraj Khanal 2022년 7월 1일
편집: Biraj Khanal 2022년 7월 1일
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 2022년 7월 1일
편집: Torsten 2022년 7월 1일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by