list = {'Undamped Condition','Underdamped Condition','Critically Damped Condition','Overdamped Condition'}; [indx,tf] = listdlg('ListString',list,'SelectionMode','single'); Code=indx; if eq(Code,1) prompt={'Enter Initial Displacement','Zeta','Spring Cosntant','Mass','Initial Velocity'}; title='Please Input the Following Values'; dims=[1 30]; definput={'5','0.01','500','5','10'}; answer=inputdlg(prompt,title,dims,definput) Initial_Displacement=str2double(answer{1}); Zeta=str2double(answer{2}); Spring_Constant=str2double(answer{3}); Mass=str2double(answer{4}); Initial_Velocity=str2double(answer{5}); Natural_Frequency=sqrt(Spring_Constant/Mass); Time=(0:0.05:6); Disp_Eqn=Initial_Displacement.*cos(Natural_Frequency.*Time) +(Initial_Velocity./Natural_Frequency).*sin(Natural_Frequen cy.*Time); plot(Time,Disp_Eqn) elseif eq(Code,2) prompt={'Enter Initial Displacement','Zeta','Spring Cosntant','Mass','Initial Velocity'}; Title='Please Input the Following Values'; dims=[1 30]; definput={'5','0.01','500','5','10'}; answer=inputdlg(prompt,title,dims,definput) Initial_Displacement=str2double(answer{1}); Zeta=str2double(answer{2}); Spring_Constant=str2double(answer{3}); Mass=str2double(answer{4}); Initial_Velocity=str2double(answer{5}); Natural_Frequency=sqrt(Spring_Constant/Mass); Time=(0:0.5:60); A=Initial_Displacement.*cos(sqrt(1Zeta.*Zeta).*Natural_Frequency.*Time); B=(Initial_Velocity+Zeta.*Natural_Frequency.*Initial_Displa cement)./(sqrt(1-Zeta.*Zeta).*Natural_Frequency);
Disp_Eqn=exp(Zeta.*Natural_Frequency.*Time).*(A+B.*sin(sqrt(1Zeta.*Zeta).*Natural_Frequency.*Time)); plot(Time,Disp_Eqn) elseif eq(Code,3) prompt={'Enter Initial Displacement','Zeta','Spring Cosntant','Mass','Initial Velocity'}; Title='Please Input the Following Values'; dims=[1 30]; definput={'5','0.01','500','5','10'}; answer=inputdlg(prompt,title,dims,definput) Initial_Displacement=str2double(answer{1}); Zeta=str2double(answer{2}); Spring_Constant=str2double(answer{3}); Mass=str2double(answer{4}); Initial_Velocity=str2double(answer{5}); Natural_Frequency=sqrt(Spring_Constant/Mass); Time=(0:0.05:6); Disp_Eqn=(Initial_Displacement+(Initial_Velocity+Natural_Fr equency.*Initial_Displacement).*Time).*exp(Natural_Frequency.*Time); plot(Time,Disp_Eqn) elseif eq(Code,4) prompt={'Enter Initial Displacement','Zeta','Spring Cosntant','Mass','Initial Velocity'}; Title='Please Input the Following Values'; dims=[1 30]; definput={'5','0.01','500','5','10'}; answer=inputdlg(prompt,title,dims,definput); Initial_Displacement=str2double(answer{1}); Zeta=str2double(answer{2}); Spring_Constant=str2double(answer{3}); Mass=str2double(answer{4}); Initial_Velocity=str2double(answer{5}); Natural_Frequency=sqrt(Spring_Constant/Mass); Time=(0:0.5:60); C1=(Initial_Displacement.*Natural_Frequency.*(Zeta+sqrt(Zet a.*Zeta1))+Initial_Velocity)./(2.*Natural_Frequency.*sqrt(Zeta.*Ze ta-1)); C2=(Initial_Displacement.*Natural_Frequency.*(Zeta+sqrt(Zeta.*Z
eta-1))Initial_Velocity)./(2.*Natural_Frequency.*sqrt(Zeta.*Zeta1)); B1=-Zeta+sqrt(Zeta.*Zeta-1); B2=-Zeta-sqrt(Zeta.*Zeta-1); Disp_Eqn=C1.*exp(B1.*Natural_Frequency.*Time)+C2.*exp(B2.*N atural_Frequency.*Time); plot(Time,Disp_Eqn) else f=msgbox('Please Select Any Option'); end