⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compress.m

📁 为stanford大学donoho教授所编写的redgit变换源代码。是用c编写的
💻 M
字号:
function [c, err] = compress(a, ratio)
% COMPRESS Compress an array
%
%	[c, err] = compress(a, ratio)
%
% The "compression" is achieved by zero-out 100*ratio percent of array
% element with smallest magnitute (hence, ratio is between 0 and 1).

if (ratio < 0) | (ratio > 1)
    error('ratio must be between 0 and 1');
end

% Sort the coefficient in the order of energy.
asort = sort(abs(a(:)));
err = cumsum(asort.^2);
err = flipud(err);

% Threshold.
mind = floor(ratio * prod(size(a)));
if (mind > 0)
    thresh = asort(mind);
    c = a .* (abs(a) > thresh);
else
    c = a;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -