Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

problem croping matrix data

6 Ansichten (letzte 30 Tage)
Maite M.
Maite M. am 24 Aug. 2016
Geschlossen: MATLAB Answer Bot am 20 Aug. 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

Antworten (1)

Thorsten
Thorsten am 24 Aug. 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.

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by