How to input scattered multivariate data to csaps - bug compared to tpaps?

62 次查看(过去 30 天)
Similar to the example in tpaps (copied below), I want to use csaps to smooth multivariate scattered, not gridded, data. While the documentation for the input "x - data sites" is identical for both tpaps and csaps, tpaps will accept a 2-by-m array of points while csaps will not.
rng(23); nxy = 31;
xy = 2*(rand(2,nxy)-.5); vals = sum(xy.^2);
noisyvals = vals + (rand(size(vals))-.5)/5;
st = tpaps(xy,noisyvals);
tpaps will accept the array xy, while csaps will not. I understand that csaps can accept multivariate data using a cell-array input to specify the points in each dimension, but based off the example in csaps this appears to require gridded sites. Is there an option for using csaps with scattered sites?
Thanks!
-Craig

采纳的回答

Sumukh
Sumukh 2024-12-2,9:46
编辑:Sumukh 2024-12-2,9:47
Hi @Craig,
Unlike other spline interpolation functions, the “tpaps” function appears to be the command that can interpolate to values at ungridded data sites in the plane, as mentioned in the following documentation:
A possible workaround to use scattered data with “csaps” function is to first convert the non-gridded data to gridded data using the “griddatan” function. You can refer to the following documentation to know more about this function:
In addition, please refer to the “Tip” tab in the above documentation that states scattered data interpolation with “griddatan” function can be sensitive to scaling issues which can be resolved using normalization.
Once the gridded data is obtained, the “csaps” function can be used to return the cubic smoothing spline interpolation in ppform. Please refer to the following example to know more about how to use the multivariate (2 in this example) gridded data as a cell array:
I hope this helps resolve the issue.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by