Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
edit-merging the values
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i have two matrices andf a code
AC=[HHH CLL]
B=A2(:,1)
AC=[1 2 3 ;5 6 7 ;8 9 0]
B=[1 ;4 ;5]
[tf, loc] = ismember(B, AC(:,1));
outC = [reshape(B(tf),[],1), AC(loc(tf), :)]
this code works now,but,i i add some strings to
AC=[HHH S CLL]
AC=[1 2 'A' 3 ;5 6 'B' 7 ;8 9 'C' 0]
this code generates error
Error using ==> cell.ismember at 28
Input must be cell arrays of strings.
Error in ==> main at 328
[tf, loc] = ismember(B, AC(:,1));
PLEASE HELP
0 commentaires
Réponses (1)
Walter Roberson
le 4 Fév 2012
You cannot mix numeric values and characters in the same numeric array.
I do not have access to test at the moment, but I suspect that
AC=[1 2 'A' 3 ;5 6 'B' 7 ;8 9 'C' 0]
is constructing a character array, equivalent of
AC=[char(1) char(2) 'A' char(3); char(5) char(6) 'B' char(7); char(8) char(9) 'C' char(0)];
If I am correct, then you would be trying to ismember() against a character array, but character arrays are not permitted for ismember() -- only numeric arrays, or character strings (row vectors), or cell arrays of strings.
2 commentaires
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!