フィルターのクリア

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 Center および File ExchangeSignal Attributes and Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by