Remove rows from table identified in a second string array
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
I have a table of results, called Results which is 505x11. The first column is Results.Filename and gives an asociated string file name for each set of results. I have a second cell array called Post_Inflate_names which is 191X1 and contains string names in the same format as Results.Filename.
I want to remove rows in Results if the filename is present in Post_Inflate_names. I have tired using the find command however there are limitations using the == operator with a table.
% One of the many failed attempts...
Remove = find(Results.Filename == Post_Inflate_names)
Results(Remove,:) = [];
I will include a few sample rows of both data in a spreadsheet.
Thanks,
Christopher
댓글 수: 0
채택된 답변
Star Strider
2021년 4월 13일
The ismember function would likely work, however the two tables you want to compare have nothing in common in the variables you want to test.
I created a third table (‘T3’) to test it:
T1 = readtable('sample.xlsx', 'Sheet',1, 'VariableNamingRule','preserve');
T2 = readtable('sample.xlsx', 'Sheet',2, 'ReadVariableNames',0);
T3(:,1) = table([T2{:,1}; T1{:,1}]);
Lv = ismember(T3{:,1}, T1{:,1});
T3_new = T3{~Lv,:}; % Remove Duplicates
That gives the correct results, at least as I interpret what you want to do. Note that this operates on the contents of the tables (using the curly bracket {} notation).
댓글 수: 2
Star Strider
2021년 4월 13일
As always, my pleasure!
Your question sent me quickly to Braunwald’s Heart Disease (10th Ed, 2015) that had essentially the same information you cited, and that I remember, although no specific definition. Of course the magnitude of the R-deflection depends on the lead. The prominence of the R-deflection is also a function of pre-exising or underlying cardiac disease, such as myocardial hypertrophy (from hypertension or aortic stenosis to consider only two possible etiologic factors) or hypertyrophic cardiomyopathy, among others. For that reason, I’m not sure that a specific definition exists. I’ll look in a few other sources, and if I find anything of interest, I’ll post back here, since that’s an interesting problem.
추가 답변 (1개)
Mathieu NOE
2021년 4월 13일
hello Christopher
thi would be my suggestion
notice I changed the last 3 names in Post_Inflate_names to get a matching case with {'001a'};{'001b'};{'001c'}
Results = readtable('sample.xlsx','VariableNamingRule','preserve');
% Post_Inflate_names = [{'003d'};{'004d'};{'006d'};{'007d'};{'008f'};{'009d'};{'010d'};{'011e'};{'014e'};{'015d'}];
Post_Inflate_names = [{'003d'};{'004d'};{'006d'};{'007d'};{'008f'};{'009d'};{'010d'};{'001a'};{'001b'};{'001c'}];
str1 = Results.Filename;
str1 = strrep(str1,'''',''); % simple quotes gone
str1 = strrep(str1,'"',''); %double quotes gone
str2 = Post_Inflate_names;
str2 = strrep(str2,'''',''); % simple quotes gone
str2 = strrep(str2,'"',''); %double quotes gone
[Names, Remove, DataIdx] = intersect(str1, str2, 'stable');
Results(Remove,:) = [];
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!