Fit a signal into smaller window while maintaiing proportion
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!