How to input scattered multivariate data to csaps - bug compared to tpaps?
62 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Sumukh
on 2 Dec 2024 at 9:46
Edited: Sumukh
on 2 Dec 2024 at 9:47
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.
More Answers (0)
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!