How to search an compare two arrays for certain criteria
2 ビュー (過去 30 日間)
古いコメントを表示
I have to arrays that are the same length with similar but not identical values. I need to compare from start to finish these arrays to see when array A is greater than or less than array B by 10% +/- 20. Once I find when those instance occur I need to plot data points 5 seconds before and 5 seconds after the event. Should I use an if and statement loop? Any help is appreciated, thanks.
2 件のコメント
Azzi Abdelmalek
2014 年 1 月 3 日
This is not clear, give a numeric example and post the expected result
回答 (1 件)
Walter Roberson
2014 年 1 月 3 日
mask = (A > 0.9 * B - 20) & (A < 1.1 * B + 20);
extended_mask = logical(filter(mask, ones(1,11)));
Now extended_mask selects the elements to be plotted. How to proceed with the actual plotting depends on what you want the output to look like when there are multiple events.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!