Linear interpolation of a 2d array to another 2d array
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
How can I linearly interpolate a rectangular 2d array (50 by 36) into a another rectagular array say (25 by 18). I know MATLAB's interp1 function can do this but unfortunately it returns "Nan" in some of the output array elements. How can I circumvent this issue ?
2 commentaires
thoughtGarden
le 20 Sep 2019
Can you give an example of what you want, say with a 2X2 and 1X2 2d array? interpolation across arrays of different sizes doesn't make much sense (and I'm not sure interp1 can do what you are looking for).
for example:
arr1 = [2,4;5,6];
arr2 = [1,3];
val = yourFunc(arr1,arr2,1.5)
what do you expect val should be?
Réponses (1)
Matt J
le 21 Sep 2019
You are getting NaN's because some of the query locations where you have asked interpolation to be performed are outside the boundaries of the array.
However, as the others have said, interpolation is a peculiar way to downsample an array. More typically, you would do 2x2 binning. If that is what you actually want, you could use this FEX file,
For example
>> A=rand(50,36);
>> B = sepblockfun(A,[2,2],'mean');
>> whos A B
Name Size Bytes Class Attributes
A 50x36 14400 double
B 25x18 3600 double
0 commentaires
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!