Resizing a small matrix to a larger one
8 次查看(过去 30 天)
显示 更早的评论
I have a matrix of some satellite data (size 446x307) and a matrix of some interpolated in-situ data (size must be a square grid i.e. NxN .. so for example I could make it 307x307). They cover the same area (I have latitude and longitude matrices for both the satellite and in-situ data as well which are 446x307 and NxN), but they are different sizes. How do I either expand the in-situ to a 446x307 matrix, or squash the satellite data into a 307x307, without losing the data? I'm needing to do this so that I can then compare the two by the individual pixels for error analysis.
I think it may be something to do with interpolating the in-situ to a larger matrix, but I'm not sure.
2 个评论
回答(2 个)
Adam
2014-8-20
griddedInterpolant
would do the job of regridding. If you don't want to lose data though you will, as you say, need to expand the smaller rather than squash the larger. That will introduce interpolated data along one dimension, but that is unavoidable I think if you are changing the x/y size ratio.
4 个评论
Adam
2014-8-20
interp2 seems to work fine with Nans for me with data as doubles. Well, when i say fine I mean it handles them. It widens them out more than I would want, but it doesn't crash or anything like that.
Image Analyst
2014-8-20
Simply use imresize(). It's a lot easier than griddedInterpolant. Not sure how imresize() handles nans though - you'd have to check. You can convert nans to zeros if you want to or need to before calling imresize().
2 个评论
Adam
2014-8-20
I keep forgetting there is an imresize function in the Image Processing Toolbox.
It does handle nans, but seems to expand them more than perhaps you might want.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!