Error using cell/ismem​ber>cellis​memberR201​2a error

2 ビュー (過去 30 日間)
sermet
sermet 2014 年 5 月 13 日
コメント済み: per isakson 2014 年 5 月 13 日
% belows came from command window not codes,
txt1 =
'p4004'
[4005]
[4007]
[4009]
[4015]
[4020]
[4031]
[4037]
[4041]
[4151]
cc =
'p4004'
Name Size Bytes Class Attributes
txt1 10x1 1202 cell global
cc 1x1 122 cell global
%when I perform this code
[row,col] = ismember(txt1,cc)
%it gives Error using cell/ismember>cellismemberR2012a error. I didn't understand what is wrong, txt1 and cc are cells. When I create txt1 and cc matrixes in workspace like txt1=[{'p4004'},{'4005'},{'4007'},{'4009'}]..... it works without any error.

採用された回答

per isakson
per isakson 2014 年 5 月 13 日
AFAIK and understand the documentation: ismember doesn't take a cell array, which contains different types of data. In your case double and string.
  2 件のコメント
sermet
sermet 2014 年 5 月 13 日
How can I fix this?
per isakson
per isakson 2014 年 5 月 13 日
You have to make txt1 a cell array of strings.
You already know that
txt1=[{'p4004'},{'4005'},{'4007'},{'4009'}];
is one way to make such an array. This creates the same result a bit simpler
txt1={'p4004','4005','4007','4009'};
How did you create
txt1 =
'p4004'
[4005]
[4007]
...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by