function f = f_axis(X,T,axis_type)
%
%  f = f_axis(X,T,axis_type)
%
%  generate a frequency axis for FFT plots
%
%  X = FFT data (results of X=FFT(x))
%  T = sampling period
%  axis_type = type of axis to create:
%              1 = Digital Rad/s [0,pi],  2 = Analog Radians/s
%              3 = Analog Hertz           4 = Normalized frequency [0,1]
%
%  Defaults if not specified:  axis_type = 3, T = 1
%
%  to plot FFT data:  plot(f,X)

%  Initial -> faxis()
%  Modified -> 03.12.96 Khomutov S.Yu.

if nargin == 2,
   axis_type = 3.0;
elseif nargin == 1,
   axis_type = 3.0;
   T = 1.0;
end

N = length(X);    % ¤«¨­  ¨áå®¤­®£® àï¤ 
n=fix(N/2)+1;     % ª®«-¢® äã­¤ ¬¥­â «ì­ëå ç áâ®â

f = (0:n-1)/N;    % f0=0; f1=1/N; f2=2/N; ..., <=1/(2T)

if axis_type == 3,
   f = f/T;
elseif axis_type == 2,
   f = f * (2*pi/T);
elseif axis_type == 4,
   f = 2 * f;
else
   f = f * (2*pi);
end
f = f';
