MATLAB: How do you delete text data from a row if its characters are equal to or less than 3

if statement

How are these data currently stored? For example, do you have them in a cell array? Or in a CSV file, not yet loaded into MATLAB?

Best Answer

If you have the data in a cell array:
C = {'Trinidad & Tobago'
'USD'
'Turkey'
'TRY'
'USD'
'Uganda'
'UGX'
'Ukraine'
'USD'
'United Arab Emirates'
'USD'
'United Kingdom'
'USD'
'United States'
'USD'
'Uruguay'
'UYU'
'Zambia'
'USD'
'NA'
'BRL'
'COP'
'CZK'
'EUR'}
then
C = C(cellfun(@(x)length(x)>3,C))
will keep only the longer entries, while
C(cellfun(@(x)length(x)<=3,C)) = {''}
will replace the 3-character entries with empty string.