Find unique rows in a cell array with mixed data types

3 Ansichten (letzte 30 Tage)
ZigzS
ZigzS am 30 Apr. 2018
Kommentiert: ZigzS am 1 Mai 2018
Hi,
I have a cell array formatted like the following:
>> stations
'WOSB' [ NaN] [ NaN]
'YOUB' [48.8266] [-121.123]
..
It contains a lot of "stations" denoted by a several character string (e.g. 'WOSB'), followed by a latitude and a longitude. A lot of the entries have NaN in the lat/long places as displayed above, and there are a ton of repeats. I want to extract the unique rows of this cell array, but when I try I get the following:
unique(stations)
Error using *cell/unique* (line xx)
Input A must be a cell array of strings.
How can I get the unique rows from this cell array with the mixed types?
Thanks,

Akzeptierte Antwort

dpb
dpb am 30 Apr. 2018
>> t=cell2table(stations)
t =
2×3 table
stations1 stations2 stations3
_________ _________ _________
'WOSB' NaN NaN
'YOUB' 48.8266 -121.123
>> unique(t,'rows')
ans =
2×3 table
stations1 stations2 stations3
_________ _________ _________
'WOSB' NaN NaN
'YOUB' 48.8266 -121.123
>>

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by