Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

problem croping matrix data

6 visualizaciones (últimos 30 días)
Maite M.
Maite M. el 24 de Ag. de 2016
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
hi I have some ASC files that represents soil moisture data. I want to crop these data to my area of interest, I do:
lon=-13.05:0.01:0.01;
lat=30.0:0.01:40.0;
[longrid,latgrid]=meshgrid(lat,lon);
spain=[-1 0 39 40];
data2=data((longrid>=spain(1))&(longrid<=spain(2))&(latgrid>=spain(3))&(latgrid<=spain(4)));
but the dimensions I obtain is: original file= 1000x1307, latgrid and longrid 1001x1307, I do not know why it is adding an extra row... with this error I can't keep going on my code
thanks for your time

Respuestas (1)

Thorsten
Thorsten el 24 de Ag. de 2016
This is because lat has 1001 values. You have to modify lat to match the spacing in your original data.
To generate 1000 values from 30 to 40, you can use
lat = linspace(30, 40, 1000)
But if this is right you have to check, based on on the boundaries of lat in your data. It could also be
lat = linspace(30, 39.99, 1000)
or
lat = linspace(30.01, 40, 1000)
or something else. linespace is always your friend, it ensures that you have the right number of values.

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by