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

25 vues (au cours des 30 derniers jours)
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

Réponse acceptée

Matt J
Matt J le 4 Nov 2025 à 19:02
Modifié(e) : Matt J le 4 Nov 2025 à 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 commentaires
Matt J
Matt J le 4 Nov 2025 à 19:50
Modifié(e) : Matt J le 4 Nov 2025 à 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 le 4 Nov 2025 à 20:16
Modifié(e) : Walter Roberson le 4 Nov 2025 à 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...

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by