%
disp(' ');
disp(' srs_rel_disp.m  ver 1.1  March 1, 2013 ');
disp(' ');
disp(' by Tom Irvine ');
disp(' ');
disp(' This script is an SRS amplitude conversion utility. ')
disp(' ');
%
clear fn;
clear omegan;
clear omn2;
%
%
disp(' Select units ');
disp('  1=English: accel(G),       vel(in/sec), disp(in)  ');
disp('  2=metric : accel(G),       vel(m/sec),  disp(mm)  ');
disp('  3=metric : accel(m/sec^2), vel(m/sec),  disp(mm)  ');
iunit=input(' ');
%
while(1)
%
    disp(' ');
    fn=input(' Enter natural frequency (Hz) ');
    omegan=2*pi*fn;
    omn2=omegan^2;
%    
    while(1)
        disp(' ');
        disp(' Select input metric: ');
        disp('   1=relative displacement ');
        disp('   2=pseudo velocity ');
        disp('   3=absolute acceleration ');
        im=input(' ');
        if(im==1 || im==2 || im==3)
            break;
        end
    end
%
    if(iunit==1) 
        if(im==1)
            rd=input(' Enter relative displacement (in) ');
            pv=rd*omegan;
            aa=rd*omn2/386;
        end
        if(im==2)
            pv=input(' Enter pseudo velocity (in/sec) ');
            rd=pv/omegan;
            aa=pv*omegan/386;
        end
        if(im==3)
            aa=input(' Enter absolute acceleration (G) ');
            pv=386*aa/omegan;
            rd=386*aa/omn2;
        end
%
        out1=sprintf('\n\n Equivalent Values at %8.4g Hz \n',fn);
        out2=sprintf('  relative displacement = %8.4g in ',rd);
        out3=sprintf('        pseudo velocity = %8.4g in/sec ',pv);
        out4=sprintf('  absolute acceleration = %8.4g G ',aa);
%
    end 
%
    if(iunit==2)
        if(im==1)
            rd=input(' Enter relative displacement (mm) ');
            pv=rd*omegan/1000;
            aa=rd*(omn2/1000)/9.81;
        end
        if(im==2)
            pv=input(' Enter pseudo velocity (m/sec) ');
            rd=1000*pv/omegan;
            aa=pv*omegan/9.81;
        end
        if(im==3)
            aa=input(' Enter absolute acceleration (G) ');
            pv=9.81*aa/omegan;
            rd=9.81*1000*aa/omn2;
        end
%
        out1=sprintf('\n\n Equivalent Values at %8.4g Hz \n',fn);
        out2=sprintf('  relative displacement = %8.4g mm ',rd);
        out3=sprintf('        pseudo velocity = %8.4g m/sec ',pv);
        out4=sprintf('  absolute acceleration = %8.4g G ',aa);
%        
    end
%
    if(iunit==3)
        if(im==1)
            rd=input(' Enter relative displacement (mm) ');
            pv=rd*omegan/1000;
            aa=rd*omn2/1000;
        end
        if(im==2)
            pv=input(' Enter pseudo velocity (m/sec) ');
            rd=1000*pv/omegan;
            aa=pv*omegan;
        end
        if(im==3)
            aa=input(' Enter absolute acceleration (m/sec^2) ');
            pv=aa/omegan;
            rd=1000*aa/omn2;
        end
%
        out1=sprintf('\n\n Equivalent Values at %8.4g Hz \n',fn);
        out2=sprintf('  relative displacement = %8.4g mm ',rd);
        out3=sprintf('        pseudo velocity = %8.4g m/sec ',pv);
        out4=sprintf('  absolute acceleration = %8.4g m/sec^2 ',aa);
%        
    end
%
    disp(out1);
    disp(out2);
    disp(out3);
    disp(out4);
%
    disp(' ');
    disp(' Perform another calculation?  1=yes 2=no ');
    ia=input(' ');
    if(ia==2)
        break;
    end
end