probably a dumb question - logical indexing
1 回表示 (過去 30 日間)
古いコメントを表示
Hello
Maybe I have forgotten the little I learned about logical indexing, but I can't think of a way to translate this into something using find function or any sort of logical indexing.
Here is what I am trying to do in terms of a loop:
for t = 1:numel(T)
if abs(T(t+4000) - T(t)) <= 0.1
tau = t;
break;
end
end
I want to compare temperature values taken throughout a given amount of time. If the difference between temperatures that are 4000 indices (timepoints in this case) apart is less than 0.1, it gives me the timepoint. This is a basic heating/cooling problem and I just want to find tau.
I feel like there is a much more computationally efficient way to do this, but other options are escaping me at the moment. Thanks
0 件のコメント
採用された回答
Sean de Wolski
2015 年 7 月 8 日
編集済み: Sean de Wolski
2015 年 7 月 8 日
tau = find(T(4001:end)-T(1:end-4000)<=0.1,1,'first')
Something like this (not tested in ML)
Though this won't be faster for very large T where tau is small because it's doing the subtraction for the entire T-4000 elements array where as the loop only runs until it stops (which could be 1 iteration).
0 件のコメント
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!