필터 지우기
필터 지우기

Resizing a small matrix to a larger one

조회 수: 8 (최근 30일)
Roseanne
Roseanne 2014년 8월 20일
댓글: Adam 2014년 8월 20일
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
Guillaume
Guillaume 2014년 8월 20일
Is it matrices or images you want to resize?
Roseanne
Roseanne 2014년 8월 20일
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.

댓글을 달려면 로그인하십시오.

답변 (2개)

Adam
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
Roseanne
Roseanne 2014년 8월 20일
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 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
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
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.
Roseanne
Roseanne 2014년 8월 20일
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?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Signal Attributes and Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by