閾値検出後データ取得
Show older comments
閾値を作成し閾値後のデータを取得する処理の方法をご教授願います。
どの様に処理をしたいかといいますと、例えば
[1, 2, 1, 0, 3, 2, 8, 2, 1, 0, 3, 6, 7, 1, 0, 3 ]
というデータがあったときに閾値5を設定して、閾値後3つデータを取得するプログラム
[1, 2, 1, 0, 3, 2, 8, 2, 1, 0, 3, 6, 7, 1, 0, 3 ]
a=[8,2,1] b=[6,7,1]
という風なプログラムを作成したいです。
何か良い方法はないでしょうか?
お手数おかけしますが、どうかお願いします。
Accepted Answer
More Answers (1)
Hiroyuki Hishida
on 28 Apr 2021
福光様、
このようなイメージでしょうか?
処理関数が不明であっても、言葉を変えて検索してみると、似た処理を行っているサンプルが見つかるかもしれません。
x=[1, 2, 1, 0, 3, 2, 8, 2, 1, 0, 3, 6, 7, 1, 0, 3 ];
t=5;
%Googleで、"matlab 条件 要素"で検索してみてください
idx=find(x>t);
C=cell(length(idx));
for i=1:length(idx)
%3つ確保できるとき
if idx(i)+2 <= length(x)
C{i}=[ x(idx(i)), x(idx(i)+1), x(idx(i)+2)];
disp(C{i});
%端部に近く、2つだけ確保できるとき
elseif idx(i)+1 <= length(x)
C{i}=[ x(idx(i)), x(idx(i)+1), NaN];
disp(C{i});
%端部で、1つだけ確保できるとき
else
C{i}=[ x(idx(i)), NaN, NaN];
disp(C{i});
end
end
菱田
Categories
Find more on Data Acquisition Toolbox Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!