1
0

Initial commit

This commit is contained in:
github-classroom[bot]
2023-09-27 06:23:10 +00:00
committed by GitHub
commit bb7f798573
38 changed files with 640 additions and 0 deletions

Binary file not shown.

BIN
Z_utils/compare_audio_files.slx Executable file

Binary file not shown.

87
Z_utils/plot_complex_sig.m Executable file
View File

@ -0,0 +1,87 @@
function plot_complex_sig(x,samples_per_symbol,Nmax,plot_style)
% plot_complex_sig(x) plots a one-dimensional complex signal as points
% in 3-D space : x-axis is the sample (time) axis, y-axis is the real part,
% and z-axis the imaginary part
%
% plot_complex_sig(x,samples_per_symbol) plots all samples in blue and
% one sample per symbol in red.
%
% plot_complex_sig(x,samples_per_symbol,Nmax) only plots the first Nmax
% samples.
%
% plot_complex_sig(x,samples_per_symbol,Nmax,'arrows') use arrows from
% (i_sample,0,0) instead of points to represent samples.
%
% version compatible with Simulink Version 7.3 (R2009a)
%% process function arguments and perform various tests on function
nargchk(1,3,nargin);
if nargin<2
samples_per_symbol = 1;
end
if (isstruct(x))
if(~isfield(x,'signals'))
error('unsupported data type')
else
if (x.signals.dimensions ~= 1)
error('does not support multidimensional signals')
else
vals = x.signals.values;
end
end
else % should be array
vals = x;
end
if nargin<3
Nmax=length(vals);
end
if nargin<4
plot_style = 'points';
end
if (~isnumeric(vals))
error('unsupported data type')
elseif (isreal(vals))
error('numbers are not complex')
end
if ((samples_per_symbol < 1) || ~(round(samples_per_symbol)==samples_per_symbol))
error('samples_per_symbol must be a strictly positive integer')
end
if ~strcmp(plot_style,'points') && ~strcmp(plot_style,'arrows')
error('possible values for plot plot_style are : "points" and "arrows"')
end
%% function implementation
sel=(1:Nmax)';
abs_max = max(abs(x(sel)));
if (samples_per_symbol==1)
if strcmp(plot_style,'points')
plot3(sel,real(vals(sel)),imag(vals(sel)),'.');
elseif strcmp(plot_style,'arrows')
quiver3(sel,zeros(size(sel)),zeros(size(sel)),zeros(size(sel)),real(vals(sel)),imag(vals(sel)),0);
end
else
plot3(sel,real(vals(sel)),imag(vals(sel)),'.');
hold on
sel= (1:samples_per_symbol:Nmax)';
if strcmp(plot_style,'points')
plot3(sel,real(vals(sel)),imag(vals(sel)),'.r');
elseif strcmp(plot_style,'arrows')
quiver3(sel,zeros(size(sel)),zeros(size(sel)),zeros(size(sel)),real(vals(sel)),imag(vals(sel)),0);
end
hold off
end
ylim([-abs_max,abs_max])
zlim([-abs_max,abs_max])
axis vis3d
grid on
xlabel('samples');
ylabel('real');
zlabel('imag');

28
Z_utils/show_histogram.m Executable file
View File

@ -0,0 +1,28 @@
function show_histogram(histogram,Vmin,Vmax)
% show_histogram((histogram,Vmin,Vmax) plots in a figure
% an histogram computed by the Signal Processing Blockset 'Histogram'
% block and exported to the Matlab Workspace through a 'Signal to
% Workspace' block. The 'Signal to Workspace' block has to be
% configured to output a one-dimensional array.
%
% histogram is the name of the variable containing the histogram
% as a one-dimensional array
% Vmin, Vmax are, respectively, the minimal input value and
% the maximal input value, as specified in the dialog box of the
% 'Histogram' block.
% compatible with Matlab R2012b
if ~isnumeric(histogram)
error('histogram is expected to be an array of numbers !');
end
if ndims(histogram)>2 || (size(histogram,1)~=1 && size(histogram,2)~=1)
error('histogram is expected to be a one-dimensional array !');
end
Nbins=length(histogram);
delta=(Vmax-Vmin)/Nbins;
hx = Vmin+delta/2:delta:Vmax;
hy = histogram;
bar(hx,hy);