%
%  find_plot_limits.m  ver 1.0  August 28, 2012
%
function[fmin,fmax,ymin,ymax]=find_plot_limits(f,a)
%
    fmin=min(f);
    fmax=max(f);
%
    for i=1:20
        for j=1:9
            level = j*10^(i-10);
            fmax=level;
            if(level>=max(f))
                break;
            end
        end
        if(level>=max(f))
            break;
        end
    end
%
    for i=1:20
        for j=1:9
            level = j*10^(i-10);
            fmin=level;
            if(min(f)<=level)
                break;
            end
        end
        if(min(f)<=level)
            break;
        end  
    end
%
    ymax=max(a);
    ymin=min(a);
%
    for(i=1:20)
        level = 10^(i-10);
        if(min(a) > level)
            ymin=level;
        end
    end
%
    for(i=1:20)
        level = 10^(10-i);
        if(max(a) < level)
            ymax=level;
        end
    end