1
%Initial condition response of mass-spring system m=1; %mass c=0; %damping constant k=1; %stiffness num=[1]; %numerator of transfer-function model for M-K system den=[m 0 k]; %denominator of transfer-function model for M-K system sys_tf=tf(num,den); %build a transfer-function system sys_ss=ss(sys_tf); %obtain a state-space system model %Investigate the state-space model of M-K system to determine %which state variables correspond to position/velocity x0=[5 2]'; %specify initial condition for M-K system time=[0:0.05:20]; %specify time vector for simulation %simulate M-K system for initial condition response [Y,T,X]=initial(sys_ss,x0,time); plot(T,Y) %Initial condition response of mass-spring-damper system m1=1; k1=1; zeta1=0.1; %under-damped system damping ratio. wn1=sqrt(k1/m1); %undamped natural frequency c1=2*m1*zeta1*wn1; %damping constant num1=[1]; den1=[m1 c1 k1]; sys_tf1=tf(num1,den1); sys_ss1=ss(sys_tf1); x01=[5 2]'; time1=[0:0.05:20]; [Y1,T1,X1]=initial(sys_ss1,x01,time1); plot(T1,Y1)

Initial

Embed Size (px)

DESCRIPTION

drive

Citation preview

  • %Initial condition response of mass-spring systemm=1; %massc=0; %damping constantk=1; %stiffnessnum=[1]; %numerator of transfer-function model for M-K systemden=[m 0 k]; %denominator of transfer-function model for M-K systemsys_tf=tf(num,den); %build a transfer-function systemsys_ss=ss(sys_tf); %obtain a state-space system model%Investigate the state-space model of M-K system to determine%which state variables correspond to position/velocityx0=[5 2]'; %specify initial condition for M-K systemtime=[0:0.05:20]; %specify time vector for simulation%simulate M-K system for initial condition response[Y,T,X]=initial(sys_ss,x0,time);plot(T,Y)%Initial condition response of mass-spring-damper systemm1=1;k1=1;zeta1=0.1; %under-damped system damping ratio.wn1=sqrt(k1/m1); %undamped natural frequencyc1=2*m1*zeta1*wn1; %damping constantnum1=[1];den1=[m1 c1 k1];sys_tf1=tf(num1,den1);sys_ss1=ss(sys_tf1);x01=[5 2]';time1=[0:0.05:20];[Y1,T1,X1]=initial(sys_ss1,x01,time1);plot(T1,Y1)