Fit a signal into smaller window while maintaiing proportion

조회 수: 1 (최근 30일)
John
John 2013년 3월 16일
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?

채택된 답변

Image Analyst
Image Analyst 2013년 3월 16일
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.

추가 답변 (0개)

카테고리

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