Info
This question is closed. Reopen it to edit or answer.
edit-merging the values
4 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Walter Roberson
on 4 Feb 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 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!