Filter löschen
Filter löschen

Resizing a small matrix to a larger one

8 Ansichten (letzte 30 Tage)
Roseanne
Roseanne am 20 Aug. 2014
Kommentiert: Adam am 20 Aug. 2014
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 Kommentare
Guillaume
Guillaume am 20 Aug. 2014
Is it matrices or images you want to resize?
Roseanne
Roseanne am 20 Aug. 2014
It is the matrices I am trying to resize. So I have latitude,longitude and a data product (which I have got from satellite data - 446x307), and then the latitude, longitude and the same data product from in-situ data - 307x307. It's just resizing would be good as then I could compare specific points (specified by latitude and longitude) for the data product.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Adam
Adam am 20 Aug. 2014
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 Kommentare
Roseanne
Roseanne am 20 Aug. 2014
Thanks for your help so far! interp2 doesn't allow NaNs (which I have when it includes land in my area), and if I were to set these to another value such as 0, it would include this value in the interpolation?
Adam
Adam am 20 Aug. 2014
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.

Melden Sie sich an, um zu kommentieren.


Image Analyst
Image Analyst am 20 Aug. 2014
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 Kommentare
Adam
Adam am 20 Aug. 2014
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.
Roseanne
Roseanne am 20 Aug. 2014
Sadly (as you saw on my question about masking coastlines), I do not have the image processing toolbox. Do you know of any similar codes for either curve fitting or statistics toolboxes?

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by