how to upscale the dimensions of a matrix to match the dimensions for a second matrix?
25 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
sherien
el 4 de Nov. de 2025 a las 19:00
Editada: Walter Roberson
el 4 de Nov. de 2025 a las 20:20
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
0 comentarios
Respuesta aceptada
Matt J
el 4 de Nov. de 2025 a las 19:02
Editada: Matt J
el 4 de Nov. de 2025 a las 19:19
Use imresize
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 comentarios
Matt J
el 4 de Nov. de 2025 a las 19:50
Editada: Matt J
el 4 de Nov. de 2025 a las 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]
Walter Roberson
el 4 de Nov. de 2025 a las 20:16
Editada: Walter Roberson
el 4 de Nov. de 2025 a las 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...
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
