{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# name - xnew = step1'name_state,x,t,deltaT xgraph(i = x(1...

This preview shows page 1. Sign up to view the full content.

%name.m %This program determines the state variables of the %following mass-spring-damper system: % %m(d2x/dt2)+c(dx/dt)+kx=0 %x(0) = 1; dx/dt(0) = 0, %m = 1; c = 2, k = 5 % %This program graphs x(t). %The state equations are contained in the M-file %called name_state.m % clear % %perform 1st-order numerical integration % x(1)=1; x(2)=0; %initial conditions deltaT = 0.01; N = 500; %step size and number of steps for i = 1: N t = (i-1)*deltaT;
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: xnew = step1('name_state',x,t,deltaT); xgraph(i) = x(1); time(i) = t; x = xnew; end figure %graph y(x) hold grid plot(time,xgraph,'--') % % perform 2nd-order numerical integration % x2(1)=1; x2(2)=0; % initial conditions for i = 1: N t2 = (i-1)*deltaT; xnew2 = step2('name_state',x2,t2,deltaT); xgraph2(i) = x2(1); time2(i) = t2; x2 = xnew2; end % % graph y(x) % plot(time2,xgraph2)...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online