Remove rows from table identified in a second string array

2 views (last 30 days)
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

Accepted Answer

Star Strider
Star Strider on 13 Apr 2021
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 Comments
Christopher McCausland
Christopher McCausland on 13 Apr 2021
Thank you for your response, it works well!
Annoyingly I had just found ismember, I hadn't considered it for table operations, its rather handy to say the least!
While I have you here could I also ask you a cardiology question?
The American Heart Association defines STEMI criteria for computer interprated ECG readings with ST elevation, ST depression and t-wave changes being considered. One of the criteria given is a prominet R-wave or R/S >1. While R/S > 1 is easy to define I cannot find a definition for a prominet R-wave other than clinicains 'eye-balling it'. I can think of a couple of way to define it , hard threshold, R/T > x etc. however I was wondering if you knew of any texts that state an official definition?
Thanks again for all your help!
Christopher
Star Strider
Star Strider on 13 Apr 2021
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.

Sign in to comment.

More Answers (1)

Mathieu NOE
Mathieu NOE on 13 Apr 2021
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,:) = [];

Tags

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!