function iaplot1D(f,x,plotopt)
%
% iaplot1D(f,x,plotopt)
%
% plots the distribution of the inclination angles of a 2d rough surface z=f(x,y).
%
% Input:  f       - surface height
%         x       - surface point
%         plotopt - plotting option (type 'hist' for drawing a histogram,
%                   type 'plot' for plotting distribution in a continuous
%                   approximation) 
%
% Last updated: 2009-03-02 (David Bergström)
%

[normx normy] = normals1D(f,x); % normal estimation
[NZ,X] = hist(acos(normy),100); % histogram of inclination angles

if nargin<3 || isempty(plotopt)
    fprintf('No plotting option specified. Type \''help iaplot2D\'' for further details.\n');
    return;
end;
if nargin==3 
    if ischar(plotopt)
        switch plotopt
            case {'hist','HIST'}
                bar(X*180/pi,NZ);
                xlabel('Angle of inclination \theta (deg)');
                ylabel('Inclination angle distribution');
            case {'plot','PLOT'}
                plot(X*180/pi,NZ);
                xlabel('Angle of inclination \theta (deg)');
                ylabel('Inclination angle distribution');
            otherwise 
                fprintf('%s is not a valid option. Type \''help iaplot2D\'' for further details.\n',plotopt);
        end;
    else fprintf('Option must be a string. Type \''help iaplot2D\'' for further details.\n');
    end;
end;