pkg load signal
graphics_toolkit gnuplot
clear all; close all; clc
betas = [2 8 24 100];
alphas = betas/pi
colors = [0 0 1; 0 1 0; 0 1 1; 1 0 1]; %blue green cyan magenta
hfig = figure;
grid on; hold on; box on
N = 128; % Relative curve shapes are not sensitive to this number
set(gca, "XTick",[0 : 1/8 : 1]*2*N,...
"XTickLabel",[" 0"; " "; " "; " "; " "; " "; " "; " "; "2N-1 "])
set(gca, "YTick",[0 0.2 0.4 0.6 0.707 0.8 1.0] )
xlim([0 2*N])
ylim([0 1.05])
for k= 1:length(betas)
w = besseli(0,betas(k)*sqrt(1-(2*(0:N)/N -1).^2))/besseli(0,betas(k));
d = zeros(1,2*N); % length 2N
for n=0:N-1
d(1+n) = sum(w(1+(0:n)));
end
for n=N:2*N-1
d(1+n) = sum(w(1+(0:2*N-1-n)));
end
d = sqrt(d/sum(w(1+(0:N))));
plot(0:2*N-1, d, "color", colors(k,:), "linewidth", 2)
end
title("Kaiser-Bessel-derived window functions")
ylabel(" ") % create left margin
text(8, .96, 'd_n', "fontsize", 14)
text(100, -0.05, '\leftarrow n \rightarrow')
%h = legend('\pi\alpha= 2; \alpha=0.64', '\pi\alpha= 8; \alpha=2.55',...
% '\pi\alpha= 24; \alpha=7.64', '\pi\alpha=100; \alpha=31.8');
%But let's do it a less "manual" way:
h = legend(['\pi\alpha= ' num2str(betas(1),'%3i') '; \alpha=' num2str(betas(1)/pi,'%5.2f')],...
['\pi\alpha= ' num2str(betas(2),'%3i') '; \alpha=' num2str(betas(2)/pi,'%5.2f')],...
['\pi\alpha= ' num2str(betas(3),'%3i') '; \alpha=' num2str(betas(3)/pi,'%5.2f')],...
['\pi\alpha=' num2str(betas(4),'%3i') '; \alpha=' num2str(betas(4)/pi,'%5.2f')],...
"location","south");
legend boxoff
set(h, "fontsize",10);
% The following print() converts plain-text Greek characters in text() strings into Symbol font,
% but legend() crashes it. The set() succeeds, but generates warnings, some of which are
% diabled by warning().
% print(hfig,"-dsvg","-color",'C:\Users\BobK\Kbd-window.svg')
warning("off", "Octave:missing-glyph");
set(h, "fontname","Symbol");