필터 지우기
필터 지우기

Extract matrix subset based on latitude and longitude

조회 수: 4 (최근 30일)
Janet Reimer
Janet Reimer 2016년 10월 24일
편집: Kirby Fears 2016년 10월 24일
I have a matrix of data and want to extract various subsets (0.5 degree grids) based on latitude and longitude. My file is not one that I downloaded from NASA, ect...
I have been trying to use "find" where latitude and longitude are columns 1 & 2 of the matrix "all_time":
x=all_time(:,3:15);% tem=find(all_time(:,1)<27.5 & all_time(:,1)>28.0 & all_time(:,2)<-79 & all_time(:,2)>-78.5); box1=x(tem);
I am trying to extract boxes of 0.5 by 0.5 degrees for all the variables in columns 3 to 15 of the matrix. My box1 is an empty matrix.
Thanks

답변 (1개)

Kirby Fears
Kirby Fears 2016년 10월 24일
편집: Kirby Fears 2016년 10월 24일
Janet,
These conditions are contradictory:
all_time(:,1)<27.5 & all_time(:,1)>28.0
None of your values could be below 27.5 and above 28 at the same time. I suppose you meant to flip those comparators as:
all_time(:,1)>27.5 & all_time(:,1)<28.0
Also, tem will contain the rows satisfying your longitude and latitude conditions. If you'd like to extract all columns of x corresponding to those rows, you'd index like this:
box1=x(tem,:);
Hope this helps.
  댓글 수: 2
Janet Reimer
Janet Reimer 2016년 10월 24일
Yes, thank you, I had inadvertently flipped the signs, but "box1" is still empty.
Kirby Fears
Kirby Fears 2016년 10월 24일
편집: Kirby Fears 2016년 10월 24일
Are you sure you have data in that matrix meeting all conditions? You can try removing one condition at a time to see which one is causing a problem. You might need to use a >= or <= sign.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Vector Volume Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by