Having trouble getting this find work properly
2 ビュー (過去 30 日間)
古いコメントを表示
I have two cell arrays where the first one is time converted into serial date and the second cell array (bb) which has specific times associated with other data in it. I'm trying to extract the rows in bb in chronological order by using time cell array. BB cell array is a 1x34 cell array where each cell once expanded is a nx7 array.
I am rather new at this, but I came up with this, and I can't get this working correctly as well as do what I want it to do. Not even sure if it is in the right direction.
I'm trying to find the serial date in the test1 file in all columns of bb (1x34) and extract it into another matrix when I call the first row of time (test1). BB's {1x34}(nx7) the column 7 of the nx7 is the serial date for that BB.
for i=1:length(test1)
for t=1:length(bb)
for w=1:length(bb{t})
[a{t} b(w,1:7)]=find(bb{t}(w,1:7)==test1(i)
end
end
end
0 件のコメント
回答 (1 件)
KSSV
2016 年 12 月 20 日
don't use find, check with ismemebr, ismemebrtol.
6 件のコメント
KSSV
2016 年 12 月 21 日
You fix a small parameter eps and subtract them.
eps = 10^-6 ;
idx = test1(589)-bb{1}(1,:)<eps
so in idx if any value is 1, then you can say they are equal. Using == for flottant numbers is not advisable. Also, I suggested you to use ismembertol.
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!