extract valuable data from signal
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
FeiMing
am 15 Dez. 2012
Kommentiert: Mansour Aljohani
am 25 Jul. 2015
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.
For example like: https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRVDJyqxKO-48fA07OdnPPLfPIwFpXg8AqbmoDwAQ-X4dK-5bOJ
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.
1 Kommentar
Akzeptierte Antwort
Image Analyst
am 16 Dez. 2012
Bearbeitet: Image Analyst
am 16 Dez. 2012
Try something like this, where I take the absolute value, then filter it to get rid of the oscillating parts, then take the difference, and finally extract the 5 bursts:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format longg;
format compact;
fontSize = 20;
% Generate sample data.
signal = 0.003 * rand(1, 550) - 0.0015
signal(50:100) = 0.03 * rand(1, 51) - 0.015
signal(150:200) = 0.03 * rand(1, 51) - 0.015
signal(250:300) = 0.03 * rand(1, 51) - 0.015
signal(350:400) = 0.03 * rand(1, 51) - 0.015
signal(450:500) = 0.03 * rand(1, 51) - 0.015
subplot(3, 1, 1);
plot(signal);
title('Original Signal', 'FontSize', fontSize);
grid on;
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Take absolute value and median filter to get rid of oscillations.
filteredSignal = medfilt1(abs(signal), 13);
subplot(3, 1, 2);
plot(filteredSignal);
title('Filtered Signal', 'FontSize', fontSize);
% Find the quiet parts between the bursts.
quietParts = filteredSignal < 0.002;
subplot(3, 1, 3);
plot(quietParts, 'LineWidth', 3);
ylim([0 1.2]);
title('Quiet Parts', 'FontSize', fontSize);
% Find the starting and ending elements of the bursts.
startingBlockIndexes = find(diff(quietParts) < 0)
endingBlockIndexes = find(diff(quietParts) > 0)
% Extract the 5 blocks (known to be exactly 5)
v1 = signal(startingBlockIndexes(1):endingBlockIndexes(1));
v2 = signal(startingBlockIndexes(2):endingBlockIndexes(2));
v3 = signal(startingBlockIndexes(3):endingBlockIndexes(3));
v4 = signal(startingBlockIndexes(4):endingBlockIndexes(4));
v5 = signal(startingBlockIndexes(5):endingBlockIndexes(5));
% Plot the 5 signals.
figure;
subplot(5, 1, 1);
plot(v1);
grid on;
title('V1', 'FontSize', fontSize);
subplot(5, 1, 2);
plot(v2);
grid on;
title('V2', 'FontSize', fontSize);
subplot(5, 1, 3);
plot(v3);
grid on;
title('V3', 'FontSize', fontSize);
subplot(5, 1, 4);
plot(v4);
grid on;
title('V4', 'FontSize', fontSize);
subplot(5, 1, 5);
plot(v5);
grid on;
title('V5', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
2 Kommentare
Image Analyst
am 17 Dez. 2012
OK, well as you know, you did not provide your data so I had to make up some. Of course it may need to be tweaked to work with your data. Glad I could point you in the right direction. Mark it as Answered if you're all done with this discussion.
Weitere Antworten (1)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!