-
Notifications
You must be signed in to change notification settings - Fork 0
/
cardinalSinShifted.m
54 lines (48 loc) · 1.3 KB
/
cardinalSinShifted.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
% FILE: cardinalSinShifted
%
% FUNCTION: cardinalSinShifted
%
% CALL: hn = cardinalSinShifted(M, wc, Ts)
%
% Evaluates the sampled version of a continous sinc in M
% points with the sampling period Ts
%
% INPUTS:
% M - the length of the discrete sinc
% wc - the cutoff "frequency"
% Ts - sampling period
%
% OUTPUTS:
% hn - discrete cardinal sin
% Author: Leonard-Gabriel Necula
% Created: December 24 2020
% Updated: January 18 2021
%
function hn = cardinalSinShifted(M, wc, Ts)
if nargin < 1
M = 16;
disp('Order was not set. Set order to 16');
elseif isempty(M)
M = 16;
disp('Order was left empty. Set order to 16');
end
if nargin < 2
wc = 0.4 * pi;
disp('Cutoff frequency was not set. Set wc to 0.4pi');
elseif isempty(wc)
wc = 0.4 * pi;
disp('Cutoff frequency was left empty. Set wc to 0.4pi');
end
if nargin < 3
disp('The sampling period was not set. Ts set to 1');
Ts = 1;
elseif isempty(Ts)
disp('The sampling period was left empty. Ts set to 1');
Ts = 1;
end
n = 0:M-1;
hn = wc/(pi * Ts) * sin(wc*(n - (M-1)/2))./(wc*(n - (M-1)/2));
if mod(M,2)
hn((M-1)/2 + 1) = wc/(pi * Ts);
end
end