select data from specific range
4 次查看(过去 30 天)
显示 更早的评论
Dear all,
My file have 3 column and more than hundred line..First column represent latitude, second longitude and lastly sea level. My plan is to average the sea level data based on specific range of latitude and longitude..I try design the program but still not work..Let say my file name is 200012.txt and i try to extract sea level data in range of (2<lat<3) & (95<lon<97)..But still not success. Help me
f=load('200012.txt'); lat=f(:,1); lon=f(:,2); sla=f(:,3);
x=sla(find((2<lat<3) & (95<lon<97)))
采纳的回答
Chandra Kurniawan
2011-12-25
Hello,
I have a text file formated :
1 90 100
1 96 101
1 95 102
2 91 103
2 96 104
1 89 105
3 87 106
3 96 107
2 90 108
4 97 109
2 76 110
And Here the script :
clear; clc;
f = load('200012.txt');
lat = f(:,1);
lon = f(:,2);
sla = f(:,3);
%x = sla(find((2<lat<3) & (95<lon<97)))
r = sla(find(lat >=2 & lat <= 3 & lon >=95 & lon <= 97))
The Result :
r =
104
107
7 个评论
Chandra Kurniawan
2011-12-25
No, I think you can't do that.
i = 2 : 0.25 : 15; %size 1x53
j = 95 : 0.25 : 126; %size 1x125
Coz, the size of i and j must be same.
更多回答(4 个)
Chandra Kurniawan
2011-12-25
If size of i and j are same, then
f = load('200012.txt');
lat = f(:,1);
lon = f(:,2);
sla = f(:,3);
i = 2 : 0.25 : 15;
j = 95 : 0.25 : 126;
for x = 1 : numel(i)-1
r = sla(find(lat >=i(x) & lat <= i(x+1) & lon >= j(x) & lon <= j(x+1)))
b = mean(r)
end
This code I just use x = 1 : 53
Image Analyst
2011-12-25
Try something like this (I didn't test it):
rowsToAverage = lat>2 & lat<3 & lon>95 & lon<97;
meanValue = mean(sla(rowsToAverage));
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!