Spline coordinates from spap2

11 ビュー (過去 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 Center および File ExchangeSpline Construction についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by