how to upscale the dimensions of a matrix to match the dimensions for a second matrix?

조회 수: 25 (최근 30일)
Hi,
I have a rainfall matrix with dimensions (106*88). I need to upscale the matrix to match the matrix of black carbon (bc_aod) with the dimesions (17*18). I'm uploading the two matrices, with the latitude and longtide for each matrix. (lat,lon)=rain; (latc,lonc)= bc_aod. I'll be gratefull if anyone help me to upscale the rainfall matrix then plot the original rainfall matrix, and the upscaled matrix.
Thanks in advance

채택된 답변

Matt J
Matt J 2025년 11월 4일 19:02
편집: Matt J 2025년 11월 4일 19:19
load Carbon
load Rain
rainResized = imresize(rain, OutputSize=size(bc_aod));
tiledlayout('h')
nexttile
imagesc(rain); axis off; axis image;colormap('gray'); title Original
nexttile
imagesc(rainResized); axis off; axis image;colormap('gray'); title Resized
  댓글 수: 3
Matt J
Matt J 2025년 11월 4일 19:50
편집: Matt J 2025년 11월 4일 19:53
I have never heard of the "simple average method". If you mean you want to divide the matrix into non-overlapping tiles and average together all the pixels in each tile, then it is not applicable because the two sets of dimensions do not differ by integer multiples,
[106,88]./[17,18]
ans = 1×2
6.2353 4.8889
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Walter Roberson
Walter Roberson 2025년 11월 4일 20:16
편집: Walter Roberson 2025년 11월 4일 20:20
Your rainfall matrix has 106 rows; your carbon matrix has 17 rows. In order to use a simple averaging method, the ratio 106 to 17 would have to be an integer... but it is 6.23529411764706 instead. So the first 6 rows of your rainfall matrix would have to be used completely to make up the first resized row... but what of the 7th row? 0.235 of it needs to be used, and that isn't something that you can get by simple averaging.
it is possible to use averaging, but it requires that you replicate the source matrix 17 times and then average every 106 rows of the resulting expanded matrix.
You run into the same problem with the columns, except it is a different expansion factor...

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by