1
0
This repository has been archived on 2024-09-17. You can view files and clone it, but cannot push or open issues or pull requests.
SDI-TransmissionProcesses/show_histogram.m

28 lines
971 B
Mathematica
Raw Permalink Normal View History

2023-09-27 06:23:10 +00:00
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);