%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %This script file is to run simulate a bouncy non- %compression-force spring %by Andy Ruina on 2/20/97 % Two or three dimensional simulation of a mass on % a spring that can carry no compression force. clear all global k Lzero m g jhat n k=29; m=1; Lzero=3; g=10; %note the special results if Lzero=0 z0=[2 1 0 0 0 0]; %put 4 or 6 numbers here for a 2D or 3D simulation n=length(z0)/2; % n is the number of dimensions 2, or 3 jhat = zeros(1,n); jhat(2) = 1; % jhat is a unit vector in y dir t0=0; tf=10; tol=1E-4; [t,z]=ode23('springfn', t0, tf, z0, tol); %Here are some plotting options: (1), (2), and (3) % 1) comet is kind of cool %comet(z(:,1), z(:,2)); % 2) double plot %subplot(2,1,1) %plot(z(:,1), z(:,2)); axis('equal') ; %xlabel('x'); ylabel('y'); title('Andy Ruina plot 2/20/97') %subplot(2,1,2) %plot(t, z(:,2)) %xlabel('t'); ylabel('y') % 3) 3D Plot plot3 ( z(:,1), z(:,2), z(:,3) ) axis('equal') %end of script file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%