problem with cell array e unique
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Luca Re
le 30 Août 2023
Réponse apportée : Star Strider
le 30 Août 2023
>> class(RankList)
ans =
'cell'
>> typeRank=unique(cell2table(RankList))
Error using tabular/unique
Unable to group rows using unique values of the table variable 'RankList'. UNIQUE returned an error.
Caused by:
Error using matlab.internal.math.uniqueCellstrHelper
Cell array input must be a cell array of character vectors.
0 commentaires
Réponse acceptée
Star Strider
le 30 Août 2023
There are 9 empty cells in ‘RankList’ and they were causing the problem.
Try this —
LD = load('matlab_RankList.mat')
RankList = LD.RankList
idx = cellfun(@(x)~isempty(x), RankList); % Logical Vector
Empty_Cells = nnz(~idx)
RankListFull = RankList(idx) % Non-Empty Entries
RankListUnique = unique(RankListFull) % Unique Entries (Sorted)
RankListUnique = unique(RankListFull, 'stable') % Unique Entries (Un-sorted)
.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!