Info

This question is closed. Reopen it to edit or answer.

edit-merging the values

4 views (last 30 days)
kash
kash on 4 Feb 2012
Closed: MATLAB Answer Bot on 20 Aug 2021
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

Answers (1)

Walter Roberson
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
kash
kash on 4 Feb 2012
OK THANKS WALTER ,can u answer my another question plz
CLL_MEAN(:,:,1) =
83.0000 83.0000 0.6469
87.0000 87.0000 0.2616
;
;
;
;
CLL_MEAN(:,:,50) =
90.0000 90.0000 -0.1415
96.0000 96.0000 0.6981
i used
CLL_MEAN = [CLL_combinations(:,1:2,:) mean(CLL_combinations(:,3:end,:),2)]
can u tell how to display only the 2nd and 3rd column in
CLL_MEAN plz
Walter Roberson
Walter Roberson on 4 Feb 2012
c2 = CLL_MEAN(:,2,:); c3 = CLL_MEAN(:,3,:);
[c2(:), c3(:)]

This question is closed.

Tags

Community Treasure Hunt

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

Start Hunting!