- Create a Coarse Grid: Define your n-dimensional coarse grid over the hypercube using ndgrid or meshgrid for lower dimensions.
- Simulate Data on the Coarse Grid: Obtain or simulate the data values at these coarse grid points.
- Define the Fine Grid: Create a finer grid that represents the potential query points. This grid should be much denser than the coarse grid.
- Track Interpolation Queries: Use a custom wrapper around the interpn function to track which points on the coarse grid are being queried during interpolation. You can achieve this by modifying the interpolation process to log the indices of the coarse grid points used for each interpolation call.
- Generate Heat Map: Initialize an n-dimensional array (of the same size as your coarse grid) to zero. Every time a grid point is used in interpolation, increment its corresponding value in this array. Optionally, normalize the heat map to visualize the frequency of queries.
Identify Grid Data Required during Intepolation
1 view (last 30 days)
Show older comments
I'm trying to figure out a way to identify which grid points are queried when doing a n-D interpolation. The general problem is:
I have a large n-Dimensional hypercube bounding the data I need. Since it is very expensive to fill in a fine grid across that whole hypercube, I wish to initially generate a very coarse grid over the hypercube and get data points. I will then use that data to run through the simulations for which the interpolation is needed. From that, I want to identify what points on a finer grid would be required by the simulation. Ideally, I could generate something like a heat map, where I can count the number of times each data point gets called, so I could determine to what fidelity I need to obtain data. In addition, this will let me identify which points in the cube can be ignored, which I expect to be 90-95% of the total.
My first thought is to dig into the interpn function and find where it queries the grid and modify it for my purposes, but I'm open to an existing or more elegant approach.
0 Comments
Answers (1)
Prateekshya
on 3 Oct 2024
Hello Zach,
To tackle the problem of identifying which grid points are queried during an n-D interpolation and potentially generating a heat map of those queries, you can use a combination of MATLAB's interpolation capabilities and some custom logic to track the queries. Here is how to do it:
I hope it helps!
0 Comments
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!