One can use importdata
-
data = importdata(filepath1) %%// filepath1 is the path to the text file
num_occ = 3; %%// Minimum limit to no. of occurances for data to be kept
unqvals = unique(data(:,1))
data = data(~ismember(data(:,1),unqvals(histc(data(:,1),unqvals)<num_occ)),:)
datacell = cellstr(num2str(data));
fileID = fopen(filepath1,'w');
for k = 1:size(datacell,1)
fprintf(fileID,'%s\n',datacell{k,:});
end
fclose(fileID);
Please remember that it will over-write data into the input file, as asked in comments.