function [S,F]=a_spectr(x,dt,g)
%Âû÷èñëåíèå àìïëèòóäíîãî ñïåêòðà äë? âðåìåííîãî ð?äà è åãî
%ðèñîâàíèå
%
%Âûçîâ:  [S,F]=a_spectr(x,[dt,[g]]);
%
%  x - âðåìåííîé ð?ä äëèòåëüíîñòè N;
% dt - èíòåðâàë äèñêðåòèçàöèè [ïî óìîë÷àíèþ - 1];
%  g - ïðèçíàê ðèñîâàíè? (0/1) [ïî óìîë÷àíèþ - íå ðèñîâàòü(=0)];
%
%  S - àìïëèòóäíûé ñïåêòð;
%  F - ÷àñòîòû äë? ðàçìåòêè îñè;

if nargin==1
   dt=1; g=0;
elseif nargin==2
   g=0;
end

N=length(x);
a=fft(x);         % FFT
S=p_gramm(a,2);   % amplitude spectrum
F=f_axis(a,dt);
% .................. spectrum plot
ttt=['Step between points ' num2str(dt) '; Number of points - ' num2str(N)];
if g==1
   plot(F,S), title(ttt)
   xlabel('Frequency'), ylabel('Amplitude spectrum')
end
