Commit b3d1d96f authored by Marina Kreme's avatar Marina Kreme
Browse files

add fucntions

parent c40fccbe
Pipeline #5941 passed with stage
in 5 minutes and 13 seconds
function w = compute_ambiguity_function(w, dgt ,apply_fftshift)
%% x = compute_ambiguity_function(x, dgt ,fftshift_)
% Compute the ambiguity function of the window
%
% Inputs:
% - w (nd array): vector
% - dgt (handle): DGT operator. see utils/get_stft_operators.m
% -apply_fftshift: Boolean If true, shift the window in time before
% computing its DGT.
%
%Author: Marina KREME
%%
switch apply_fftshift
case 'True'
w = dgt(fftshift(w));
case 'False'
w = dgt(w);
otherwise
fprintf('Incorrect value fftshift_\n')
end
function mask = generate_rectangular_mask(nbins, hop, sig_len, t_lim, f_lim)
%% GENERATE_RECTANGULAR_MASK
% Generate a rectangular time-frequency mask
% mask = generate_rectangular_mask(nbins, hop, sig_len, t_lim, f_lim)
% Inputs:
% - nbins: numbers of frequency bins (int)
% - hop : hop size (int)
% - sig_len: signal length (int)
% - t_lim : time boundaries of the mask
% - f_lim : frequency boundaries of the mask
%
% Outputs:
% - mask : the boolean 2D array containing the time-frequency mask (True values)
%
% Author : A. Marina KREME
%%
M = nbins/2 +1;
N = sig_len/hop;
if size(f_lim,2)~=2 || size(t_lim,2)~=2
error("Incorrect value. f_lim or t_lim must be an interval")
end
mask = zeros(M,N);
f_lim = round(f_lim*size(mask,1));
t_lim =round(t_lim*size(mask,2));
mask(f_lim(1):f_lim(2),t_lim(1):t_lim(2))=1;
end
function plot_ambiguity_function(x, dgt , dgt_params, signal_params,...,
dynrange, apply_fftshift)
%% plot_ambiguity_function(x, dgt , dgt_params, signal_params, dynrange)
%
% This function compute and plot ambiguity function for a given vector
%
% Inputs:
% - x: signal
% -dgt: Gabor transform operator
% - dgt_params: Signals parameters(sig_len, fs)
% - signal_params: Discrete Gabor Transform parameters(hop, nbins,win, ect..)
% - dynrange : dynamic range (optional)
%
% Author: Marina KREME
%%s
apply_fftshift = [upper(apply_fftshift(1)),apply_fftshift(2:end)];
if nargin==4
dynrange = 100;
apply_fftshift='True';
end
if nargin==5
apply_fftshift='True';
end
x = compute_ambiguity_function(x, dgt ,apply_fftshift);
plotdgtreal(x, dgt_params.hop, dgt_params.nbins, signal_params.fs,'dynrange', dynrange)
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment