Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

problem croping matrix data

6 visualizzazioni (ultimi 30 giorni)
Maite M.
Maite M. il 24 Ago 2016
Chiuso: MATLAB Answer Bot il 20 Ago 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

Risposte (1)

Thorsten
Thorsten il 24 Ago 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.

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by