finding unique string variables from a column vector

2 ビュー (過去 30 日間)
antonet
antonet 2012 年 6 月 4 日
Dear all,
I insert an excel file into matlab as follows
clear
clear all
[data,text,all] = xlsread(A.xlsx');
mdata0=[all];
mdata1=num2cell(mdata0);
and I want to use the command
ismember(mdata1(:,5),unique(mdata1(:,5)))
where mdata1(:,5) contains string variables
but whenever I issue that command I get
??? Error using ==> cell.unique at 47
Input must be a cell array of strings.
Any suggestions?
thanks

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 6 月 4 日
[data,text,alld] = xlsread('A.xlsx');
mdata1 = alld(:,5);
t = cellfun(@(x)isnumeric(x),mdata1);
mdata1(t) = cellfun(@(x)num2str(x),mdata1(t),'un',0);
[out,out]= ismember(mdata1,unique(mdata1));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by