name - xnew = step1('name_state',x,t,deltaT); xgraph(i) =...

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

View Full Document Right Arrow Icon
%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;
Background image of page 1
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

This note was uploaded on 09/17/2009 for the course MAE 469 taught by Professor Silverberg during the Fall '08 term at N.C. State.

Ask a homework question - tutors are online