function func = freqcut ( fmax );
% FreqCut
%
% Filtering by FFT
% data by P. Pickel, U Halle
%
% Parameter: 
%   fmax   (input)  : cut-off frequency
%
% Example
%   freqcut ( 1.0 );   % print -dpng ../png/freqcut1.png
%   freqcut ( 2.0 );   % print -dpng ../png/freqcut2.png
%   freqcut ( 5.0 );   % print -dpng ../png/freqcut5.png
%   freqcut ( 0.5 );   % print -dpng ../png/freqcut05.png
%
%
% Author :      Martin Arnold, martin.arnold@mathematik.uni-halle.de
% Version of :  Nov 30, 2005

graphwidth  = 24.0;
graphheight = 12.8;
facv	    =  0.99;
shiftv	    =  2.0;
fach	    =  1.0;
shifth	    =  0.0;

papershift  =  0.0;

ActFontSize   = 14;
ActLineWidth  =  3;
ActMarkerSize =  8;
RatioFlag     =  0;

border      = 1.0;

%
% -> Bestimme Groesse des Bildschirms und Skalierungsfaktor fuer die Ausgabe
root = 0;
set ( root, 'Units', 'centimeters' );
screensize = get ( root, 'ScreenSize' );
left   = screensize(1);
bottom = screensize(2);
width  = screensize(3);
height = screensize(4);
set ( root, 'Units', 'pixels' );
if RatioFlag==0,
  screenscale = 1.0;
elseif RatioFlag==1,
  screenscale = (width-2*border) / graphwidth;
end;

%
% -> Definiere den Bildschirmausschnitt
if length ( get ( root, 'Children' ) ) == 0,
  h = figure;
else
  h = gcf;
  clf;
end;
set ( h, 'Units',    'centimeters' );
set ( h, 'Position', ...
  [ left+width-screenscale*graphwidth-border height-2*border-screenscale*graphheight ...
    screenscale*graphwidth                   screenscale*graphheight ] );
set ( h, 'Units',    'pixels' );

%
% -> Skalierung der Ausgabe in PostScript
%
set ( gcf, 'PaperUnits',    'centimeters' );
set ( gcf, 'PaperPosition', [ papershift papershift graphwidth graphheight ] );

%
% -> data
h = load ( '../dat/Hhwayre.dat' );
N = length(h);

delx = 0.05;
v    = 2.0;

delt = delx / v;
fin  = 1.0 / delt;

tmin = 0;
tmax = delt * (N-1);
t = tmin:delt:tmax;

hmin = -0.1;
hmax =  0.1;

tzmin =  0.0;
tzmax = 10.0;

%
% -> discrete Fourier transform
c = fft ( h );

jmax = ceil ( fmax / fin * N / 2 );
cout = c;
cout(1+(jmax+1:N-jmax-1)) = 0;

%
% -> Der Plot
for iplot=1:2,
    subplot ( 2, 1, iplot );
    hlin = plot ( t, ifft(cout), '-g' );
    hold on;
    if iplot==1,
        set ( hlin, 'LineWidth', 4 );
        hdat = plot ( t, h, '-b', 'LineWidth', 1 );
        axis ( [ tmin tmax hmin hmax ] );
        title ( sprintf('fmax = %4.1f [Hz]',fmax) );
    elseif iplot==2,
        set ( hlin, 'LineWidth', 2 );
        hdat = plot ( t, h, '+b', 'MarkerSize', 2 );
        axis ( [ tzmin tzmax hmin hmax ] );
    end;
    hold off;
    xlabel ( 'Zeit  t [s]' );
    ylabel ( 'Vertikale Auslenkung' );
end;

%
% -> Korrektur der Groesse und Lage der Koordinatensysteme
allax = get ( gcf, 'Children' )';
for ax = allax,
  rect    = get ( ax, 'Position' );
  rect(2) = rect(2) + shiftv * (1-facv) * rect(4);
  rect(4) = facv * rect(4);
  rect(1) = rect(1) + shifth * (1-fach) * rect(3);
  rect(3) = fach * rect(3);
  set ( ax, 'Position', rect );
  set ( ax, 'FontSize', ActFontSize );
  set ( get ( ax, 'XLabel' ), 'FontSize', ActFontSize );
  set ( get ( ax, 'YLabel' ), 'FontSize', ActFontSize );
  set ( get ( ax, 'Title' ), 'FontSize', ActFontSize );
end;

% -> legend

% if iplot==1,
%     legend ( hdat, 'Fahrweg (Ackerboden)' );
% elseif iplot==2,
%     legend ( [ hdat, hspl ], 'Messdaten', 'Splineapproximation' );  ...
%            % , 'Location', 'SouthEast' );
%     set ( gca, 'DataAspectRatio', [ 1 1 1 ] );
% end;
