Fit a signal into smaller window while maintaiing proportion

1 visualización (últimos 30 días)
I have a random signal of 2048 points. There are several peaks spread out (maybe 10). The rest are all zeros or have very low amplitude.
I want to squeeze this signal into a 512 signal window maintaining all the peaks and data with less of the zeros or low amplitude data.
How can I do this in Matlab?

Respuesta aceptada

Image Analyst
Image Analyst el 16 de Mzo. de 2013
You can sort and then keep just the 512 with the highest values:
data = rand(1, 2048);
subplot(2, 1, 1);
plot(data);
% Sort the data
[sortedData, sortIndices] = sort(data, 'descend');
% Find the first 512 - they will be the greatest value.
elementsToKeep = sortIndices(1:512);
% Get them back in their original order:
elementsToKeep = sort(elementsToKeep);
% Extract those elements
extractedData = data(elementsToKeep);
subplot(2, 1, 2);
plot(extractedData);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
That's one way to do it.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by