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

59 visualizaciones (últimos 30 días)
Craig
Craig el 29 de Nov. de 2024 a las 15:48
Comentada: Craig el 2 de Dic. de 2024 a las 19:18
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

Respuesta aceptada

Sumukh
Sumukh el 2 de Dic. de 2024 a las 9:46
Editada: Sumukh el 2 de Dic. de 2024 a las 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.

Más respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by