Filter out NaNs but not lose data completely?

6 views (last 30 days)
Hello!
I have some 3d data (x, y, z coordinates in 3 columns; x and y are physical coordinates, z is the result of a measurement) from multiple scans, with these I would like to create an averaged image (averaged in z, the data in x and y is always the same for all scans, i.e. the resolution matches). The individual scans have sporadic NaNs in the z dimension. So far I had created some averaged images by simply adding all the z data together, filtering out the x, y and z rows where there are NaNs in z, finally dividing z with the number of scans that are to be averaged and putting all the columns back together.
However, because the NaNs in z are kind of random, now I encounter a problem that there are more NaNs than I expected, which then in the averaged image eats away too much of the data, especially since I average about 10 images or so.
Is there a way for me not to filter the NaNs out completely but to do something of the following kind:
If all z values at cetrain x and y are NaN → then delete x-y-z row as described above;
If from z values at certain x and y only some are NaN → keep row by using average of non-NaN z-values as the new, averaged z?
Best regards!

Accepted Answer

KSSV
KSSV on 5 Jan 2021
You can fill those NaN's using multiple ways. Read about fillmissing. You can also use interpolation methods to fill those nanas. Read about scattredInteprolant.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!