Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

problem croping matrix data

조회 수: 4 (최근 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