Filter rows and columns (find)
이전 댓글 표시
I load ('Lat_and_Lon.mat') load('Lat_and_Lon.mat') is in the following google drive link because it is larger than 5 MB (https://drive.google.com/drive/folders/18GgPs-iN3brZHQ3pZNK8GyLt4SOmemY8?usp=drive_link)
The following script is performing processing to filter rows and columns and then cross-reference them.
clc; clear
load('Lat_and_Lon.mat')
%lat_h12v09 = lat_h12v09';
%lon_h12v09 = lon_h12v09';
%load('dat_era5_201001.mat', 'lat');
%lat = lat_h12v09;
%load('dat_era5_201001.mat', 'lon');
%lon = lon_h12v09;
% lat_idx = find(lat >= & lat <=); % índices das latitudes dentro do intervalo desejado
% lon_idx = find(lon >= & lon <= ); % índices das longitudes dentro do intervalo desejado
intervaloLat = [-3, -2];%[-2.9580, -2.8231];
intervaloLon = [-55,-54];%[-60.0372,-59.9023];
latDentroDoIntervalo = lat_h12v09 >= intervaloLat(1) & lat_h12v09 <= intervaloLat(2);
lonDentroDoIntervalo = lon_h12v09 >= intervaloLon(1) & lon_h12v09 <= intervaloLon(2);
%latDentroDoIntervalo = latDentroDoIntervalo'; lonDentroDoIntervalo = lonDentroDoIntervalo';
LatIndex=find(all(latDentroDoIntervalo,1));
%%
LonIndex = [];
for lin = 1:size(lonDentroDoIntervalo, 2)
indices = find(lonDentroDoIntervalo(lin,:) == 1);%(:, col) == 1);
if ~isempty(indices)
LonIndex = [lin LonIndex];
end
end
%%
lat_resultado = lat_h12v09(LonIndex,LatIndex);%lat_h12v09(RowIndex,ColIndex);
lon_resultado = lon_h12v09(LonIndex,LatIndex');%lon_h12v09(RowIndex,ColIndex);
Note that I have lon_result and lat_result. When I conduct my test to check if my bounding filter is correct according to the square plot plus the values of lon_result and lat_result, lon_result comes out larger than it should be, unlike lat_result which is correct.
%test to check if lon_resultado and lat_resultado are within the delimitation intervaloLat = [-3, -2]; intervaloLon = [-55,-54]
% Coordenadas do quadrado
intervaloLat = [-3, -2];%[-2.9580, -2.8231];
intervaloLon = [-55,-54];%[-60.0372,-59.9023];
x = [intervaloLon(1), intervaloLon(2), intervaloLon(2), intervaloLon(1), intervaloLon(1)];
y = [intervaloLat(1), intervaloLat(1), intervaloLat(2), intervaloLat(2), intervaloLat(1)];
% Crie o gráfico do quadrado com fundo transparente
figure;
plot(x, y, 'b','LineWidth',2); % 'b' para linhas azuis, você pode alterar a cor conforme necessário
hold on, plot(lon_resultado,lat_resultado)
Does anyone have an alternative for my filtering to stay within the delimited square?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Timetables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
