필터 지우기
필터 지우기

extract and store valuable data in vectors

조회 수: 1 (최근 30일)
Mansour Aljohani
Mansour Aljohani 2015년 7월 25일
댓글: Mansour Aljohani 2015년 7월 27일
I have a signal (vector) consists of many blocks (for example five blocks).I want to extract, separate, these blocks (that contain a valuable information ) from the main signal and store every block in a vector. This is real data and the 5 valuable information in the example are not always in same location.
For example like:
So if I have an input vector (V), The result , in our case, should be five mini vectors (v1, v2, v3, v4, v5).
I tried to apply this method: If a specific consecutive elements from (V) vector have a value above a threshold (for example 0.02 > Thr) start put the elements in a a mini vector, but it does not work because values in the input vector (V) are getting positive and negative.

채택된 답변

Image Analyst
Image Analyst 2015년 7월 26일
Simple thresholding won't work because in each burst there are dips that you probably want to keep. Luckily for you I solved this same problem for another person in this discussion: http://www.mathworks.com/matlabcentral/answers/229678#answer_185935 :
% Setup - read in the signal and plot it.
s=load('signal.mat')
signal = s.coarse_d;
subplot(3,1,1);
plot(signal, '-', 'Color', [0,.5,0]);
grid on;
% MAIN CODE IS THE FOLLOWING TWO LINES OF CODE.
% Threshold the signal
lowSignal = abs(signal) < 0.1;
% Remove stretches less than 10,000 elements long.
% And invert it to get the high signal areas instead of the quiet areas.
lowSignal = ~bwareaopen(lowSignal, 10000);
% Now we're done. Plot the results.
subplot(3,1,2);
plot(lowSignal, 'b-', 'LineWidth', 2);
grid on;
% Plot both on the same graph now.
subplot(3,1,3);
plot(signal, '-', 'Color', [0,.5,0]);
hold on;
plot(lowSignal, 'b-', 'LineWidth', 2);
grid on;
As you can see it identifies each "block" but leaves the inside of the block intact.
  댓글 수: 5
Image Analyst
Image Analyst 2015년 7월 27일
I don't think I have that data anymore. I can use yours if you upload it. Like Jan says, because each chunk may be different lengths, it will have to be a cell array, not a regular numerical matrix.
Mansour Aljohani
Mansour Aljohani 2015년 7월 27일
Dear Sir, I attached my data. And thank you so much for your help.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jan
Jan 2015년 7월 26일
편집: Jan 2015년 7월 27일
What about using the absolute value of V?
T = (abs(V) > Thresh);
blockStart = strfind(T, [false, true]);
blockEnd = strfind(T, [true, false]);
But even then the signal can have a value below the threshold during a block.
[EDITED]
You can use Fex: RunLength to remove short gaps:
T = (abs(V) > Thresh);
% To fill gaps with less than e.g. 3 frames:
[B, N, Idx] = RunLength(T);
gap = find((B == false) & (N < 3)); % Two frames
T(gap) = true;
T(gap+1) = true;
blockStart = strfind(T, [false, true]) + 1;
blockEnd = strfind(T, [true, false]);
% Split signal into blocks:
Block = cell(1, length(blockStart));
for k = 1:length(BlockStart)
Block{k} = V(blockStart(k):blockEnd(k));
end

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by