Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = 1;
- gam = 0;
- om0 = 5;
- tmax = 10;
- c = 1;
- a1 = 0.5;
- I1 = @(t) Impulse(t,c,a1);
- options1 = odeset( 'MaxStep', a1 );
- a2 = 0.25;
- I2 = @(t) Impulse(t,c,a2);
- options2 = odeset( 'MaxStep', a2 );
- a3 = 0.05;
- I3 = @(t) Impulse(t,c,a3);
- options3 = odeset( 'MaxStep', a3 );
- % a4 = 0.01;
- % I4 = @(t) Impulse(t,c,a4);
- % options4 = odeset( 'MaxStep', a4 );
- [t15a,x15a] = ode15s( @(t,x) [x(2); I1(t) - om0^2*x(1) - 2*gam*x(2)], [0 tmax], [0; 0], options1 );
- [t15b,x15b] = ode15s( @(t,x) [x(2); I2(t) - om0^2*x(1) - 2*gam*x(2)], [0 tmax], [0; 0], options2 );
- [t15c,x15c] = ode15s( @(t,x) [x(2); I3(t) - om0^2*x(1) - 2*gam*x(2)], [0 tmax], [0; 0], options3 );
- % [t15d,x15d] = ode15s( @(t,x) [x(2); I4(t) - om0^2*x(1) - 2*gam*x(2)], [0 tmax], [0; 0], options4 );
- figure();
- plot( t15a,x15a(:,1), t15b,x15b(:,1), t15c,x15c(:,1));
- xlabel('t');
- ylabel('y');
- legend( 'a = 0.5', 'a = 0.25', 'a = 0.05');
- %% 2
- tsol = [0:.1:8];
- [tsol,xsol]= ode45( @(t,x) [x(2); I1(t) - 2*gam*x(2)], [tsol], [0; 0] );
- plot(tsol,xsol)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement