MATLAB: How to remove cells that have two or more occurrences in a file

duplicatesunique

I have a text file with around 1M lines of data. Here's a small snippet:
155809966
6K0809966B
6N0815478B41
6U0817940
7H0817940A
1H0819055B01C
1H0819055C01C
1H0819056
7M0819056
4H1819429A
I need to find all codes that only occur once in the text file. I have tried doing it like this:
A=textread('test.txt','%s');
B= unique(A);
Y = histc(A,B)<2;
A(sort(X(Y)))
Part of the code was taken from here. Problem is, histc can only be used with real non-sparse numeric arrays and my text file contains letters as well.
What would be the most efficient way to do this?
Sorry if I'm missing something obviuos, I'm new to Matlab.

Best Answer

I created some duplicates to demonstrate this code:
A = {'155809966'
'6K0809966B'
'6N0815478B41'
'6N0815478B41' % Duplicated

'6U0817940'
'7H0817940A'
'1H0819055B01C'
'1H0819055B01C' % Duplicated
'1H0819055C01C'
'1H0819056'
'7M0819056'
'4H1819429A'};
[Bu,~,ix] = unique(A);
Tally = accumarray(ix,1);
Out = Bu(Tally == 1) % List Omitting Duplicates
producing (here):
Out =
8×1 cell array
{'155809966' }
{'1H0819055C01C'}
{'1H0819056' }
{'4H1819429A' }
{'6K0809966B' }
{'6U0817940' }
{'7H0817940A' }
{'7M0819056' }
.