📄 rcosine.m
字号:
function [num, den] = rcosine(Fd, Fs, type_flag, R, Delay, tol)
%RCOSINE Designs a raised cosine filter.
% NUM = RCOSINE(Fd, Fs) designs a FIR raised cosine filter to filter a
% digital signal with the digital transfer sampling frequency Fd. The
% filter sample frequency is Fs. Fs must be larger than Fd. Fs/Fd must
% be an integer. The rolloff factor is a default of .5. The time delay
% is a default of 3, which means the filter has delay 3 / Fd second.
%
% [NUM, DEN] = RCOSINE(Fd, Fs, TYPE_FLAG) gives specific filter design
% instruction. TYPE_FLAG could be 'iir', 'sqrt', or a combination
% such as 'iir/sqrt'. The order of the string is not important.
% 'fir' Design FIR raised cosine filter (default).
% 'iir' Design using IIR raised cosine filter.
% 'normal' Design the regular raised cosine filter (default).
% 'sqrt' Design square root raised cosine filter.
% 'default' Use all of the default (FIR, Normal raised cosine filter).
%
% [NUM, DEN] = RCOSINE(Fd, Fs, TYPE_FLAG, R) specifies the
% rolloff factor. In general, it is a real number in range [0, 1].
%
% [NUM, DEN] = RCOSINE(Fd, Fs, TYPE_FLAG, R, DELAY) specifies the delay
% step. DELAY should be a positive integer. Delay/Fd will be the time
% delay in the raised cosine filter design.
%
% [NUM, DEN] = RCOSFLT(Fd, Fs, TYPE_FLAG, R, Delay, Tol) provides the
% tolerance in IIR filter design. The default value is .01.
%
% When the designed filter is a FIR filter, the output in DEN is 1.
%
% See also RCOSFLT, RCOSIIR, RCOSFIR.
% Wes Wang 10/11/95.
% Copyright (c) 1995-96 by The MathWorks, Inc.
% $Revision: 1.1 $ $Date: 1996/04/01 18:02:29 $
%assigned default value
if nargin < 6
tol = .01;
end;
%default delay
if nargin < 5
Delay = 3;
elseif Delay <= 0
error('DELAY must be a positive integer in RCOSINE.')
elseif ceil(Delay) ~= Delay
error('DELAY in RCOSINE must be an integer.')
end;
%default rolloff factor
if nargin < 4
R = .5;
elseif R < 0
error('The Rolloff factor in RCOSINE cannot be a negative number.')
end;
%default type_flag
if nargin < 3
type_flag = 'default';
elseif ~isstr(type_flag) & ~isempty(type_flag)
error('TYPE_FLAG in RCOSINE must be a string.');
end;
%not enough input varible.
if nargin < 2
error('Not enough input variable for RCOSINE.')
end;
type_flag = lower(type_flag);
%filter type.
if findstr(type_flag, 'sqrt')
filt_type = 'sqrt';
else
filt_type = 'normal';
end;
FsDFd = Fs/Fd;
if ceil(FsDFd) ~= FsDFd
error('Fs/Fd must be an integer.')
end;
%design the filter.
if findstr(type_flag, 'iir')
[num, den] = rcosiir(R, Delay, FsDFd, 1/Fd, tol, filt_type);
else
num = rcosfir(R, Delay, FsDFd, 1/Fd, filt_type);
den = 1;
end;
%end of RCOSINE.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -