matlab调和均值滤波器function y = harmonic(x)bad = find(x == 0); %filter out zerosnewx = x;newx(bad) = []; %newx is x without zerosnewx_adj = 1 ./ newx; %1 / newxmysum = sum(newx_adj(:)); %sum of all valuesy = prod(size(x)) / mysum;求代码注
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/24 03:44:36
matlab调和均值滤波器function y = harmonic(x)bad = find(x == 0); %filter out zerosnewx = x;newx(bad) = []; %newx is x without zerosnewx_adj = 1 ./ newx; %1 / newxmysum = sum(newx_adj(:)); %sum of all valuesy = prod(size(x)) / mysum;求代码注
matlab调和均值滤波器
function y = harmonic(x)
bad = find(x == 0); %filter out zeros
newx = x;
newx(bad) = []; %newx is x without zeros
newx_adj = 1 ./ newx; %1 / newx
mysum = sum(newx_adj(:)); %sum of all values
y = prod(size(x)) / mysum;
求代码注释
matlab调和均值滤波器function y = harmonic(x)bad = find(x == 0); %filter out zerosnewx = x;newx(bad) = []; %newx is x without zerosnewx_adj = 1 ./ newx; %1 / newxmysum = sum(newx_adj(:)); %sum of all valuesy = prod(size(x)) / mysum;求代码注
function y = harmonic(x) %声明这个函数(假设x是一行向量)
bad = find(x == 0); %bad是找出x为零项所在的列数
newx = x; %newx与x相等
newx(bad) = []; %除掉newx中的0,如原来为0,1,2,3,运行后为1,2,3,
newx_adj = 1 ./ newx; %取倒数
mysum = sum(newx_adj(:)); %newx_adj 元素和存储在mysum里
y = prod(size(x)) / mysum; %size(x)是指这个矩阵的大小如x=[0,1,3,5,7],运行后结果为1,5,prod的意思是连乘,就是1*5,那么结果就是5/mysum的值