Info

此问题已关闭。 请重新打开它进行编辑或回答。

problem croping matrix data

6 次查看(过去 30 天)
Maite M.
Maite M. 2016-8-24
关闭: MATLAB Answer Bot 2021-8-20
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

回答(1 个)

Thorsten
Thorsten 2016-8-24
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.

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by