How can I cut a vector getting only a specific part of it?

10 ビュー (過去 30 日間)
Danilo Ambrosio
Danilo Ambrosio 2017 年 4 月 7 日
コメント済み: Image Analyst 2017 年 4 月 8 日
I'm trying to cut a Force signal imported as a column oriented vector because the "drilling part" ( this signal was obtained from a drilling operation) is really short. The part that I'm looking for assume values clearly higher than the "noise". I need it for more than one signal and each signal was obtained in a different time acquisition so I need a generic way to apply this cut in each situation. I was thinking about the possibility to use a for cycle or something like that (I'm not an expert in C++ code) to catch the signal part that I'm looking for in order to extend this code for each file. How can I do it?

採用された回答

Image Analyst
Image Analyst 2017 年 4 月 7 日
No C++ needed - you can use MATLAB! And even do it in fewer lines of code. You can just threshold and extract. Lets say that the noise have values around 1-10, and the "good" signal you want to extract has values around 100-1000. So you can set a threshold of 50 or so and then extract only those elements (shortening the array),
goodIndexes = signal > threshold;
goodSignal = signal(goodIndexes);
or you can mask the noise elements to zero (keeping the same number of elements)
goodIndexes = signal > threshold;
maskedSignal = signal; % Initialize - make a copy;
maskedSignal(~goodIndexes) = 0; % Anything NOT a good signal is set to zero, or whatever value you want.
  2 件のコメント
Danilo Ambrosio
Danilo Ambrosio 2017 年 4 月 8 日
It works! This is an easy way to do what I was looking for. Did you know the way to cut the time vector to get the same length of the new reduced signal Force?
Image Analyst
Image Analyst 2017 年 4 月 8 日
Do the same thing to the time vector with the same indexes:
timeVector = timeVector(goodIndexes);

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Acquisition Toolbox Supported Hardware についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by