extraction of longitudes and latitudes of areas with different data from NaN

조회 수: 5 (최근 30일)
Derol sakpak
Derol sakpak 2021년 12월 23일
답변: Image Analyst 2021년 12월 23일
Good evening
please need help on matlab i have data structured like this:
data1 (50 * 60) with NaN and real values ​​and
longitude (lon) 1 * 60, latitude (lat) 1 * 50.
I would like to extract the longitudes and latitudes having real values ​​on the data1 matrix.
%% extraction des longitudes et latitudes
load('matrice_derol.mat')

답변 (2개)

Image Analyst
Image Analyst 2021년 12월 23일
You tagged chunru, but can other people answer or you only want answers from him? If you'd like to see my solution, it's here:
% Extraction des longitudes et latitudes
s = load('matrice_derol.mat')
data = s.data1;
imshow(data, [], 'InitialMagnification', 1000)
axis('on', 'image');
lat = s.lat
lon = s.lon
% If data has lon in columns, and lat in rows
% then you can get non-NaN coordinates like this:
[nonNanLat, nonNanLon] = find(~isnan(data))

Voss
Voss 2021년 12월 23일
This will take the lat/lon values where data1 has any non-NaN value at that lat/lon:
S = load('matrice_derol.mat')
S = struct with fields:
data1: [50×60 double] lat: [3.0598 3.1601 3.2605 3.3608 3.4611 3.5615 3.6618 3.7621 3.8625 3.9628 4.0631 4.1635 4.2638 4.3641 4.4645 4.5648 4.6651 4.7654 4.8658 4.9661 5.0664 5.1668 5.2671 5.3674 5.4678 5.5681 5.6684 5.7688 5.8691 5.9694 6.0698 6.1701 6.2704 6.3708 … ] lon: [9.0037 9.1041 9.2044 9.3048 9.4052 9.5055 9.6059 9.7063 9.8066 9.9070 10.0074 10.1077 10.2081 10.3085 10.4089 10.5092 10.6096 10.7100 10.8103 10.9107 11.0111 11.1114 11.2118 11.3122 11.4125 11.5129 11.6133 11.7137 11.8140 11.9144 12.0148 … ]
good_idx = ~isnan(S.data1);
good_lat = S.lat(any(good_idx,2))
good_lat = 1×19
5.4678 5.5681 5.6684 5.7688 5.8691 5.9694 6.0698 6.1701 6.2704 6.3708 6.4711 6.5714 6.6718 6.7721 6.8724 6.9728 7.0731 7.1734 7.2738
good_lon = S.lon(any(good_idx,1))
good_lon = 1×38
11.1114 11.2118 11.3122 11.4125 11.5129 11.6133 11.7137 11.8140 11.9144 12.0148 12.1151 12.2155 12.3159 12.4162 12.5166 12.6170 12.7173 12.8177 12.9181 13.0185 13.1188 13.2192 13.3196 13.4199 13.5203 13.6207 13.7210 13.8214 13.9218 14.0221

카테고리

Help CenterFile Exchange에서 Block Libraries에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by