이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Delete rows of excel if any empty cell found
조회 수: 8 (최근 30일)
이전 댓글 표시
Dear everyone,
I have an excel file containing some Stations defined in the first column (attached). Here, as shown below, I have 4 stations. Some stations contain no value (empty cell) like Station 1; and some stations not all cells have values.

Does anyone know how to delete the row if there's any cell with no value detected? In this case, there will be 3 stations left and the rows with empty cells in those 3 stations will be omited :

best regards
댓글 수: 3
Adi Purwandana
2023년 10월 13일
Walter Roberson
2023년 10월 13일
I do not see any height information in that table?
If you are trying to sort by depth see sortrows
Adi Purwandana
2023년 10월 13일
편집: Adi Purwandana
2023년 10월 13일

Attached file is the excel file. So, it must be ordered from the shorter (shallower) station to the longer one and so on... Any suggestions? I tried using sortrows but it doesn't solve.
채택된 답변
Star Strider
2023년 10월 13일
I am not certain how you want to sort the ‘Station’ by ‘shortest to the longest’.
Try this —
T1 = readtable('datax.xlsx', 'VariableNamingRule','preserve')
T1 = 24×9 table
Station Lon Lat Depth Salinity Temperature u v yyyy-mm-ddThh:mm:ss.sss
_______ ______ _____ _____ ________ ___________ _____ ______ _______________________
1 114.8 -8.16 0 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
1 114.8 -8.16 2 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
1 114.8 -8.16 4 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
1 114.8 -8.16 6 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
1 114.8 -8.16 8 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
1 114.8 -8.16 10 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
2 114.88 -8.16 0 33.981 29.324 0.11 -0.017 {'2023-10-08T00:00:00'}
2 114.88 -8.16 2 33.979 29.248 0.106 -0.011 {'2023-10-08T00:00:00'}
2 114.88 -8.16 4 33.979 29.25 0.106 -0.011 {'2023-10-08T00:00:00'}
2 114.88 -8.16 6 33.978 29.251 0.105 -0.011 {'2023-10-08T00:00:00'}
2 114.88 -8.16 8 33.978 29.251 0.105 -0.011 {'2023-10-08T00:00:00'}
2 114.88 -8.16 10 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
3 114.96 -8.16 0 33.995 29.171 0.109 -0.037 {'2023-10-08T00:00:00'}
3 114.96 -8.16 2 33.992 29.108 0.104 -0.03 {'2023-10-08T00:00:00'}
3 114.96 -8.16 4 33.992 29.11 0.102 -0.03 {'2023-10-08T00:00:00'}
3 114.96 -8.16 6 33.992 29.114 0.102 -0.03 {'2023-10-08T00:00:00'}
T1{:,end} = cellfun(@(x)datetime(x, 'InputFormat','yyyy-MM-dd''T''HH:mm:ss', 'Format','yyyy-MM-dd HH:mm:ss'), T1{:,end}, 'Unif',0)
T1 = 24×9 table
Station Lon Lat Depth Salinity Temperature u v yyyy-mm-ddThh:mm:ss.sss
_______ ______ _____ _____ ________ ___________ _____ ______ _______________________
1 114.8 -8.16 0 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
1 114.8 -8.16 2 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
1 114.8 -8.16 4 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
1 114.8 -8.16 6 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
1 114.8 -8.16 8 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
1 114.8 -8.16 10 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
2 114.88 -8.16 0 33.981 29.324 0.11 -0.017 {[2023-10-08 00:00:00]}
2 114.88 -8.16 2 33.979 29.248 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 4 33.979 29.25 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 6 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 8 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 10 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
3 114.96 -8.16 0 33.995 29.171 0.109 -0.037 {[2023-10-08 00:00:00]}
3 114.96 -8.16 2 33.992 29.108 0.104 -0.03 {[2023-10-08 00:00:00]}
3 114.96 -8.16 4 33.992 29.11 0.102 -0.03 {[2023-10-08 00:00:00]}
3 114.96 -8.16 6 33.992 29.114 0.102 -0.03 {[2023-10-08 00:00:00]}
T1 = rmmissing(T1)
T1 = 15×9 table
Station Lon Lat Depth Salinity Temperature u v yyyy-mm-ddThh:mm:ss.sss
_______ ______ _____ _____ ________ ___________ _____ ______ _______________________
2 114.88 -8.16 0 33.981 29.324 0.11 -0.017 {[2023-10-08 00:00:00]}
2 114.88 -8.16 2 33.979 29.248 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 4 33.979 29.25 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 6 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 8 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
3 114.96 -8.16 0 33.995 29.171 0.109 -0.037 {[2023-10-08 00:00:00]}
3 114.96 -8.16 2 33.992 29.108 0.104 -0.03 {[2023-10-08 00:00:00]}
3 114.96 -8.16 4 33.992 29.11 0.102 -0.03 {[2023-10-08 00:00:00]}
3 114.96 -8.16 6 33.992 29.114 0.102 -0.03 {[2023-10-08 00:00:00]}
4 115.04 -8.16 0 33.992 29.273 0.048 0.005 {[2023-10-08 00:00:00]}
4 115.04 -8.16 2 33.988 29.264 0.05 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 4 33.988 29.266 0.052 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 6 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 8 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 10 33.987 29.259 0.048 0.01 {[2023-10-08 00:00:00]}
Stations = accumarray(T1{:,1}, (1:size(T1,1)).', [], @(x){T1(x,:)})
Stations = 4×1 cell array
{0×0 double}
{5×9 table }
{4×9 table }
{6×9 table }
[sz,ix] = sort(cellfun(@(x)size(x,1), Stations));
valid = [sz(sz~=0) ix(sz~=0)]
valid = 3×2
4 3
5 2
6 4
Stations_Sorted = cat(1,Stations{valid(:,2)}) % Reordered
Stations_Sorted = 15×9 table
Station Lon Lat Depth Salinity Temperature u v yyyy-mm-ddThh:mm:ss.sss
_______ ______ _____ _____ ________ ___________ _____ ______ _______________________
3 114.96 -8.16 0 33.995 29.171 0.109 -0.037 {[2023-10-08 00:00:00]}
3 114.96 -8.16 2 33.992 29.108 0.104 -0.03 {[2023-10-08 00:00:00]}
3 114.96 -8.16 4 33.992 29.11 0.102 -0.03 {[2023-10-08 00:00:00]}
3 114.96 -8.16 6 33.992 29.114 0.102 -0.03 {[2023-10-08 00:00:00]}
2 114.88 -8.16 0 33.981 29.324 0.11 -0.017 {[2023-10-08 00:00:00]}
2 114.88 -8.16 2 33.979 29.248 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 4 33.979 29.25 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 6 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 8 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
4 115.04 -8.16 0 33.992 29.273 0.048 0.005 {[2023-10-08 00:00:00]}
4 115.04 -8.16 2 33.988 29.264 0.05 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 4 33.988 29.266 0.052 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 6 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 8 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 10 33.987 29.259 0.048 0.01 {[2023-10-08 00:00:00]}
.
댓글 수: 10
Adi Purwandana
2023년 10월 13일
편집: Adi Purwandana
2023년 10월 13일
Aha! @Star Strider exactly what I want. Anyway, is there any line I should add to re-numbering the column of Station number?
Station 3 --> Station 1
Station 2 --> Station 2
Station 4 --> Station 3
Thanks
Star Strider
2023년 10월 13일
As always, my pleasure!
I was away for a few minutes. That is exactly the approach I would have taken!
Adi Purwandana
2023년 10월 13일
편집: Adi Purwandana
2023년 10월 13일
Maybe my last question following this thread @Star Strider, do you know the way to omit the stations with the Depth layer less than a certain depth?
For example in this datasets:
Station 1 --> has 4 layers (0 m, 2 m, 4, 6);
Station 2 --> has 5 layers (0, 2, 4, 6, 8,)
Station 3 --> has 6 layers
For example, my purpose is... excluding the Stations with depth of less than 8 m depth; so that the Station 2 and Station 1 will be omited from the Stations_Sorted. So, there will be Stations with depth layer > 8 m (in this case is only Station 3) inside Stations_Sorted.
Thank you!
Star Strider
2023년 10월 14일
This will delete ‘Station’ table arrays with no ‘Depth’ value greater than 8 and will retain ‘Station’ table arrays with at least one ‘Depth’ value greater than 8, regardless of what the other ‘Depth’ values are. It also re-numbers the stations after using rmmissing so they begin at 1.
The revised version —
T1 = readtable('datax.xlsx', 'VariableNamingRule','preserve')
T1 = 24×9 table
Station Lon Lat Depth Salinity Temperature u v yyyy-mm-ddThh:mm:ss.sss
_______ ______ _____ _____ ________ ___________ _____ ______ _______________________
1 114.8 -8.16 0 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
1 114.8 -8.16 2 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
1 114.8 -8.16 4 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
1 114.8 -8.16 6 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
1 114.8 -8.16 8 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
1 114.8 -8.16 10 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
2 114.88 -8.16 0 33.981 29.324 0.11 -0.017 {'2023-10-08T00:00:00'}
2 114.88 -8.16 2 33.979 29.248 0.106 -0.011 {'2023-10-08T00:00:00'}
2 114.88 -8.16 4 33.979 29.25 0.106 -0.011 {'2023-10-08T00:00:00'}
2 114.88 -8.16 6 33.978 29.251 0.105 -0.011 {'2023-10-08T00:00:00'}
2 114.88 -8.16 8 33.978 29.251 0.105 -0.011 {'2023-10-08T00:00:00'}
2 114.88 -8.16 10 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
3 114.96 -8.16 0 33.995 29.171 0.109 -0.037 {'2023-10-08T00:00:00'}
3 114.96 -8.16 2 33.992 29.108 0.104 -0.03 {'2023-10-08T00:00:00'}
3 114.96 -8.16 4 33.992 29.11 0.102 -0.03 {'2023-10-08T00:00:00'}
3 114.96 -8.16 6 33.992 29.114 0.102 -0.03 {'2023-10-08T00:00:00'}
T1{:,end} = cellfun(@(x)datetime(x, 'InputFormat','yyyy-MM-dd''T''HH:mm:ss', 'Format','yyyy-MM-dd HH:mm:ss'), T1{:,end}, 'Unif',0)
T1 = 24×9 table
Station Lon Lat Depth Salinity Temperature u v yyyy-mm-ddThh:mm:ss.sss
_______ ______ _____ _____ ________ ___________ _____ ______ _______________________
1 114.8 -8.16 0 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
1 114.8 -8.16 2 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
1 114.8 -8.16 4 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
1 114.8 -8.16 6 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
1 114.8 -8.16 8 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
1 114.8 -8.16 10 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
2 114.88 -8.16 0 33.981 29.324 0.11 -0.017 {[2023-10-08 00:00:00]}
2 114.88 -8.16 2 33.979 29.248 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 4 33.979 29.25 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 6 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 8 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 10 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
3 114.96 -8.16 0 33.995 29.171 0.109 -0.037 {[2023-10-08 00:00:00]}
3 114.96 -8.16 2 33.992 29.108 0.104 -0.03 {[2023-10-08 00:00:00]}
3 114.96 -8.16 4 33.992 29.11 0.102 -0.03 {[2023-10-08 00:00:00]}
3 114.96 -8.16 6 33.992 29.114 0.102 -0.03 {[2023-10-08 00:00:00]}
T1 = rmmissing(T1)
T1 = 15×9 table
Station Lon Lat Depth Salinity Temperature u v yyyy-mm-ddThh:mm:ss.sss
_______ ______ _____ _____ ________ ___________ _____ ______ _______________________
2 114.88 -8.16 0 33.981 29.324 0.11 -0.017 {[2023-10-08 00:00:00]}
2 114.88 -8.16 2 33.979 29.248 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 4 33.979 29.25 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 6 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 8 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
3 114.96 -8.16 0 33.995 29.171 0.109 -0.037 {[2023-10-08 00:00:00]}
3 114.96 -8.16 2 33.992 29.108 0.104 -0.03 {[2023-10-08 00:00:00]}
3 114.96 -8.16 4 33.992 29.11 0.102 -0.03 {[2023-10-08 00:00:00]}
3 114.96 -8.16 6 33.992 29.114 0.102 -0.03 {[2023-10-08 00:00:00]}
4 115.04 -8.16 0 33.992 29.273 0.048 0.005 {[2023-10-08 00:00:00]}
4 115.04 -8.16 2 33.988 29.264 0.05 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 4 33.988 29.266 0.052 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 6 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 8 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 10 33.987 29.259 0.048 0.01 {[2023-10-08 00:00:00]}
[Su,~,s] = unique(T1.Station,'stable');
T1.Station = s % Renumber 'Station'
T1 = 15×9 table
Station Lon Lat Depth Salinity Temperature u v yyyy-mm-ddThh:mm:ss.sss
_______ ______ _____ _____ ________ ___________ _____ ______ _______________________
1 114.88 -8.16 0 33.981 29.324 0.11 -0.017 {[2023-10-08 00:00:00]}
1 114.88 -8.16 2 33.979 29.248 0.106 -0.011 {[2023-10-08 00:00:00]}
1 114.88 -8.16 4 33.979 29.25 0.106 -0.011 {[2023-10-08 00:00:00]}
1 114.88 -8.16 6 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
1 114.88 -8.16 8 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
2 114.96 -8.16 0 33.995 29.171 0.109 -0.037 {[2023-10-08 00:00:00]}
2 114.96 -8.16 2 33.992 29.108 0.104 -0.03 {[2023-10-08 00:00:00]}
2 114.96 -8.16 4 33.992 29.11 0.102 -0.03 {[2023-10-08 00:00:00]}
2 114.96 -8.16 6 33.992 29.114 0.102 -0.03 {[2023-10-08 00:00:00]}
3 115.04 -8.16 0 33.992 29.273 0.048 0.005 {[2023-10-08 00:00:00]}
3 115.04 -8.16 2 33.988 29.264 0.05 0.009 {[2023-10-08 00:00:00]}
3 115.04 -8.16 4 33.988 29.266 0.052 0.009 {[2023-10-08 00:00:00]}
3 115.04 -8.16 6 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
3 115.04 -8.16 8 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
3 115.04 -8.16 10 33.987 29.259 0.048 0.01 {[2023-10-08 00:00:00]}
Stations = accumarray(T1{:,1}, (1:size(T1,1)).', [], @(x){T1(x,:)}); % Segment Table By Station
% Stations = Stations(cellfun(@(x)~isempty(x), Stations)) % Delete Empty Cells
Lv = cellfun(@(x)any(x.Depth > 8), Stations); % Logical Vector To Select Cells With At Least One 'Depth' > 8
Stations = Stations(Lv); % Select Cells With At Least One 'Depth' > 8
[sz,ix] = sort(cellfun(@(x)size(x,1), Stations)); % Sort By Row Size
Stations_Sorted = cat(1,Stations{ix}) % Reordered
Stations_Sorted = 6×9 table
Station Lon Lat Depth Salinity Temperature u v yyyy-mm-ddThh:mm:ss.sss
_______ ______ _____ _____ ________ ___________ _____ _____ _______________________
3 115.04 -8.16 0 33.992 29.273 0.048 0.005 {[2023-10-08 00:00:00]}
3 115.04 -8.16 2 33.988 29.264 0.05 0.009 {[2023-10-08 00:00:00]}
3 115.04 -8.16 4 33.988 29.266 0.052 0.009 {[2023-10-08 00:00:00]}
3 115.04 -8.16 6 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
3 115.04 -8.16 8 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
3 115.04 -8.16 10 33.987 29.259 0.048 0.01 {[2023-10-08 00:00:00]}
.
Adi Purwandana
2023년 10월 14일
Great as always!
My curious question... If I want to re-numbering the stations again (here for example I only consider the station with depth >6m), it gives:

Do you know the line I should modify if I want to re-numbering the stations again, so that:
Station 1 --> Station 1
Station 3 --> Station 2
Thank you!
Adi Purwandana
2023년 10월 14일
Solved, sorry!
[Su,~,s] = unique(Stations_Sorted.Station,'stable');
Stations_Sorted.Station = s;
Star Strider
2023년 10월 14일
Thank you!
As always, my pleasure!
The only thing that comes to mind is to mpve these assignments:
[Su,~,s] = unique(T1.Station,'stable');
T1.Station = s % Renumber 'Station'
to later in the code.
This re-numbers them and then re-sorts them —
T1 = readtable('datax.xlsx', 'VariableNamingRule','preserve')
T1 = 24×9 table
Station Lon Lat Depth Salinity Temperature u v yyyy-mm-ddThh:mm:ss.sss
_______ ______ _____ _____ ________ ___________ _____ ______ _______________________
1 114.8 -8.16 0 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
1 114.8 -8.16 2 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
1 114.8 -8.16 4 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
1 114.8 -8.16 6 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
1 114.8 -8.16 8 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
1 114.8 -8.16 10 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
2 114.88 -8.16 0 33.981 29.324 0.11 -0.017 {'2023-10-08T00:00:00'}
2 114.88 -8.16 2 33.979 29.248 0.106 -0.011 {'2023-10-08T00:00:00'}
2 114.88 -8.16 4 33.979 29.25 0.106 -0.011 {'2023-10-08T00:00:00'}
2 114.88 -8.16 6 33.978 29.251 0.105 -0.011 {'2023-10-08T00:00:00'}
2 114.88 -8.16 8 33.978 29.251 0.105 -0.011 {'2023-10-08T00:00:00'}
2 114.88 -8.16 10 NaN NaN NaN NaN {'2023-10-08T00:00:00'}
3 114.96 -8.16 0 33.995 29.171 0.109 -0.037 {'2023-10-08T00:00:00'}
3 114.96 -8.16 2 33.992 29.108 0.104 -0.03 {'2023-10-08T00:00:00'}
3 114.96 -8.16 4 33.992 29.11 0.102 -0.03 {'2023-10-08T00:00:00'}
3 114.96 -8.16 6 33.992 29.114 0.102 -0.03 {'2023-10-08T00:00:00'}
T1{:,end} = cellfun(@(x)datetime(x, 'InputFormat','yyyy-MM-dd''T''HH:mm:ss', 'Format','yyyy-MM-dd HH:mm:ss'), T1{:,end}, 'Unif',0)
T1 = 24×9 table
Station Lon Lat Depth Salinity Temperature u v yyyy-mm-ddThh:mm:ss.sss
_______ ______ _____ _____ ________ ___________ _____ ______ _______________________
1 114.8 -8.16 0 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
1 114.8 -8.16 2 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
1 114.8 -8.16 4 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
1 114.8 -8.16 6 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
1 114.8 -8.16 8 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
1 114.8 -8.16 10 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
2 114.88 -8.16 0 33.981 29.324 0.11 -0.017 {[2023-10-08 00:00:00]}
2 114.88 -8.16 2 33.979 29.248 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 4 33.979 29.25 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 6 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 8 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 10 NaN NaN NaN NaN {[2023-10-08 00:00:00]}
3 114.96 -8.16 0 33.995 29.171 0.109 -0.037 {[2023-10-08 00:00:00]}
3 114.96 -8.16 2 33.992 29.108 0.104 -0.03 {[2023-10-08 00:00:00]}
3 114.96 -8.16 4 33.992 29.11 0.102 -0.03 {[2023-10-08 00:00:00]}
3 114.96 -8.16 6 33.992 29.114 0.102 -0.03 {[2023-10-08 00:00:00]}
T1 = rmmissing(T1)
T1 = 15×9 table
Station Lon Lat Depth Salinity Temperature u v yyyy-mm-ddThh:mm:ss.sss
_______ ______ _____ _____ ________ ___________ _____ ______ _______________________
2 114.88 -8.16 0 33.981 29.324 0.11 -0.017 {[2023-10-08 00:00:00]}
2 114.88 -8.16 2 33.979 29.248 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 4 33.979 29.25 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 6 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 8 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
3 114.96 -8.16 0 33.995 29.171 0.109 -0.037 {[2023-10-08 00:00:00]}
3 114.96 -8.16 2 33.992 29.108 0.104 -0.03 {[2023-10-08 00:00:00]}
3 114.96 -8.16 4 33.992 29.11 0.102 -0.03 {[2023-10-08 00:00:00]}
3 114.96 -8.16 6 33.992 29.114 0.102 -0.03 {[2023-10-08 00:00:00]}
4 115.04 -8.16 0 33.992 29.273 0.048 0.005 {[2023-10-08 00:00:00]}
4 115.04 -8.16 2 33.988 29.264 0.05 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 4 33.988 29.266 0.052 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 6 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 8 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 10 33.987 29.259 0.048 0.01 {[2023-10-08 00:00:00]}
% [Su,~,s] = unique(T1.Station,'stable');
% T1.Station = s % Renumber 'Station'
Stations = accumarray(T1{:,1}, (1:size(T1,1)).', [], @(x){T1(x,:)}) % Segment Table By Station
Stations = 4×1 cell array
{0×0 double}
{5×9 table }
{4×9 table }
{6×9 table }
Stations = Stations(cellfun(@(x)~isempty(x), Stations)) % Delete Empty Cells
Stations = 3×1 cell array
{5×9 table}
{4×9 table}
{6×9 table}
Lv = cellfun(@(x)any(x.Depth > 6), Stations) % Logical Vector To Select Cells With At Least One 'Depth' > 8
Lv = 3×1 logical array
1
0
1
Stations = Stations(Lv); % Select Cells With At Least One 'Depth' > 8
Stations
Stations = 2×1 cell array
{5×9 table}
{6×9 table}
[sz,ix] = sort(cellfun(@(x)size(x,1), Stations)); % Sort By Row Size
Stations_Sorted = cat(1,Stations{ix}) % Reordered
Stations_Sorted = 11×9 table
Station Lon Lat Depth Salinity Temperature u v yyyy-mm-ddThh:mm:ss.sss
_______ ______ _____ _____ ________ ___________ _____ ______ _______________________
2 114.88 -8.16 0 33.981 29.324 0.11 -0.017 {[2023-10-08 00:00:00]}
2 114.88 -8.16 2 33.979 29.248 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 4 33.979 29.25 0.106 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 6 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
2 114.88 -8.16 8 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
4 115.04 -8.16 0 33.992 29.273 0.048 0.005 {[2023-10-08 00:00:00]}
4 115.04 -8.16 2 33.988 29.264 0.05 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 4 33.988 29.266 0.052 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 6 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 8 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
4 115.04 -8.16 10 33.987 29.259 0.048 0.01 {[2023-10-08 00:00:00]}
[Su,~,s] = unique(Stations_Sorted.Station,'stable');
Stations_Sorted.Station = s % Renumber 'Station'
Stations_Sorted = 11×9 table
Station Lon Lat Depth Salinity Temperature u v yyyy-mm-ddThh:mm:ss.sss
_______ ______ _____ _____ ________ ___________ _____ ______ _______________________
1 114.88 -8.16 0 33.981 29.324 0.11 -0.017 {[2023-10-08 00:00:00]}
1 114.88 -8.16 2 33.979 29.248 0.106 -0.011 {[2023-10-08 00:00:00]}
1 114.88 -8.16 4 33.979 29.25 0.106 -0.011 {[2023-10-08 00:00:00]}
1 114.88 -8.16 6 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
1 114.88 -8.16 8 33.978 29.251 0.105 -0.011 {[2023-10-08 00:00:00]}
2 115.04 -8.16 0 33.992 29.273 0.048 0.005 {[2023-10-08 00:00:00]}
2 115.04 -8.16 2 33.988 29.264 0.05 0.009 {[2023-10-08 00:00:00]}
2 115.04 -8.16 4 33.988 29.266 0.052 0.009 {[2023-10-08 00:00:00]}
2 115.04 -8.16 6 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
2 115.04 -8.16 8 33.988 29.267 0.052 0.009 {[2023-10-08 00:00:00]}
2 115.04 -8.16 10 33.987 29.259 0.048 0.01 {[2023-10-08 00:00:00]}
.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
