Create location Index from cell arrays

1 回表示 (過去 30 日間)
Brian
Brian 2012 年 7 月 17 日
I have a small piece of code that loops through an array and creates an Index location of that value in another cell array. According to the code profiler, this small little loop is taking up 75% of the time of my entire script. I have a smaller cell array (Mutual Fund Portfolio) called 'FundHlds'. What I do with this loop is find the location of each identifer from this array in my larger list, another cell array called 'UniqueList'. Once I create this Index, I can then compare everything in my current portfolio to the information contained in the UniqueList cell array via the Index. I'd like to get rid of this loop method because it's very slow, and the help documentation states that strmatch will be going away in the future. Does anyone know a better way to do this?
for t = 1:length(FundHlds)
bl(t,1) = strmatch(FundHlds(t),UniqueList);
end
Thanks a lot, Brian

採用された回答

Walter Roberson
Walter Roberson 2012 年 7 月 17 日
[tf, idx] = ismember(FundHlds, UniqueList);
  1 件のコメント
Brian
Brian 2012 年 7 月 17 日
Excellent. I had never used the ismmeber command for an Index before. In fact I don't even know if I had used it with text.
Thanks much

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by