Page 378 - MATLAB an introduction with applications
P. 378

Direct Numerical Integration Methods ———  363


                      v(:,i)=(X(:,i+1)–X(:,i–1)).*(1/(2*dt));
                      a(:,i)=(X(:,i+1)–2*X(:,i)+X(:,i–1)).*(1/dt^2);
                      end
                      end
                      t=[0:dt:T+dt];
                      plot(t,X(1,:),’–p’,t,X(2,:),’–*’);
                     xlabel(‘time(s)’);
                      ylabel(‘displacement(m)’);
                      legend(‘DOF-1’,’DOF-2',2);
                      grid on;

                   The output of the program is as follows:
                                 time            X(1)           X(2)
                               0.000000        0.000000        0.000000
                               0.050000       -0.000000        0.001250
                               0.100000        0.000015        0.004998
                               0.150000        0.000067        0.011243
                               0.200000        0.000178        0.019981
                               0.250000        0.000376        0.031210
                               0.300000        0.000688        0.044924
                               0.350000        0.001142        0.061120
                               0.400000        0.001762        0.079793
                               0.450000        0.002571        0.100937
                               0.500000        0.003586        0.124545
                               0.550000        0.004821        0.150611
                               0.600000        0.006281        0.179128
                               0.650000        0.007969        0.210088
                               0.700000        0.009880        0.243481
                               0.750000        0.012004        0.279301
                               0.800000        0.014325        0.317535
                               0.850000        0.016824        0.358176
                               0.900000        0.019481        0.401212
                               0.950000        0.022271        0.446631
                               1.000000        0.025170        0.494422
   373   374   375   376   377   378   379   380   381   382   383