看不懂的一段 matlab源码 高手请帮忙解释一下程序的具体含义 谢谢了 急救 !! 100
function[N,ff,aa,wts]=remezord(fcuts,mags,devs,fsamp,cellflag)error(nargchk(3,5,nargi...
function [N, ff, aa, wts] = remezord(fcuts, mags, devs, fsamp, cellflag)
error(nargchk(3,5,nargin))
typ = 'Bandpass';
if nargin == 3,
fsamp = 2;
end
fcuts = fcuts/fsamp;
if any(fcuts > 1/2),
error('Band-edge frequencies must be less than the Nyquist frequency.');
end
if any(fcuts < 0),
error('Band-edge frequencies must be positive.');
end
fcuts = fcuts(:);
mags = mags(:);
devs = devs(:);
[mf,nf] = size(fcuts);
[mm,nm] = size(mags);
[md,nd] = size(devs);
nbands = mm;
if length(mags) ~= length(devs)
error('A and DEV must be vectors of the same length.')
end
if mf ~= 2*(nbands-1)
error('Length of F must be 2*length(A)-2.')
end
zz = mags==0;
devs = devs./(zz+mags);
f1 = fcuts(1:2:(mf-1));
f2 = fcuts(2:2:mf);
[df,n] = min(f2-f1);
if( nbands==2 )
L = remlpord( f1(n), f2(n), devs(1), devs(2));
else
L = 0;
for i=2:nbands-1,
L1 = remlpord( f1(i-1), f2(i-1), devs(i), devs(i-1) );
L2 = remlpord( f1(i), f2(i), devs(i), devs(i+1) );
L = max( [L; L1; L2] );
end
end
N = ceil( L ) - 1; % need order, not length, for remez
ff = [0;2*fcuts;1];
am(1:2:2*nbands-1) = mags;
aa = [am';0] + [0;am'];
wts = ones(size(devs))*max(devs)./devs;
if (aa(end) ~= 0) & rem(N,2),
N = N+1;
end
if nargout == 1 & nargin == 5
N = {N, ff, aa, wts};
end
function L = remlpord(freq1, freq2, delta1, delta2 )
AA = [-4.278e-01 -4.761e-01 0;
-5.941e-01 7.114e-02 0;
-2.660e-03 5.309e-03 0 ];
d1 = log10(delta1);
d2 = log10(delta2);
D = [1 d1 d1*d1] * AA * [1; d2; d2*d2];
%
bb = [11.01217; 0.51244];
fK = [1.0 (d1-d2)] * bb;
%
df = abs(freq2 - freq1);
%
L = D/df - fK*df + 1;
% [EOF] - REMEZORD.M 展开
error(nargchk(3,5,nargin))
typ = 'Bandpass';
if nargin == 3,
fsamp = 2;
end
fcuts = fcuts/fsamp;
if any(fcuts > 1/2),
error('Band-edge frequencies must be less than the Nyquist frequency.');
end
if any(fcuts < 0),
error('Band-edge frequencies must be positive.');
end
fcuts = fcuts(:);
mags = mags(:);
devs = devs(:);
[mf,nf] = size(fcuts);
[mm,nm] = size(mags);
[md,nd] = size(devs);
nbands = mm;
if length(mags) ~= length(devs)
error('A and DEV must be vectors of the same length.')
end
if mf ~= 2*(nbands-1)
error('Length of F must be 2*length(A)-2.')
end
zz = mags==0;
devs = devs./(zz+mags);
f1 = fcuts(1:2:(mf-1));
f2 = fcuts(2:2:mf);
[df,n] = min(f2-f1);
if( nbands==2 )
L = remlpord( f1(n), f2(n), devs(1), devs(2));
else
L = 0;
for i=2:nbands-1,
L1 = remlpord( f1(i-1), f2(i-1), devs(i), devs(i-1) );
L2 = remlpord( f1(i), f2(i), devs(i), devs(i+1) );
L = max( [L; L1; L2] );
end
end
N = ceil( L ) - 1; % need order, not length, for remez
ff = [0;2*fcuts;1];
am(1:2:2*nbands-1) = mags;
aa = [am';0] + [0;am'];
wts = ones(size(devs))*max(devs)./devs;
if (aa(end) ~= 0) & rem(N,2),
N = N+1;
end
if nargout == 1 & nargin == 5
N = {N, ff, aa, wts};
end
function L = remlpord(freq1, freq2, delta1, delta2 )
AA = [-4.278e-01 -4.761e-01 0;
-5.941e-01 7.114e-02 0;
-2.660e-03 5.309e-03 0 ];
d1 = log10(delta1);
d2 = log10(delta2);
D = [1 d1 d1*d1] * AA * [1; d2; d2*d2];
%
bb = [11.01217; 0.51244];
fK = [1.0 (d1-d2)] * bb;
%
df = abs(freq2 - freq1);
%
L = D/df - fK*df + 1;
% [EOF] - REMEZORD.M 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询