selecting multiple strinfs of variables
1 回表示 (過去 30 日間)
古いコメントを表示
Dear all,
I have produced the following output
county interst rate
England b1
England b1
England b1
England b1
England b2
England b2
England b2
England b3
England b3
England b4
England b4
The above table says that for England we have different types of interest rate. I would like to select the values of interest rates that correspond to both bi and b2.
If I use the command
strcmp(mdata1(:,2),'b1')
i select only b1. But I want to select both b1 and b2 Any suggestions?
thanks in advance,
stef
0 件のコメント
採用された回答
Titus Edelhofer
2012 年 5 月 14 日
Hi Stef,
I guess you are looking for ismember:
ismember(mdata(:,2), {'b1' 'b2'})
Titus
その他の回答 (1 件)
ektor
2012 年 5 月 14 日
2 件のコメント
Titus Edelhofer
2012 年 5 月 14 日
The values you have seem to be a cell array. Convert it to a double array:
doubleArray = cell2mat(cellArray);
Then you can use it lile
ismember(mdadata(:,2), {'b1' 'b2'}) & (doubleArray==0 | doubleArray==7)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!