quiz7_solution - ylabel'Distance(m title'Forced Harmonic...

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

View Full Document Right Arrow Icon
function [] = resonance_onefunc() %RESONANCE_SCRIPT - a function that solves the differential %equation m*(d2x/dt2) = -k*x - F*cos(w*t) of a forced harmonic oscillator %for x(t) and v(t). File written by S.C. Tegler. Last modified 3/21/11. tspan=[0 3]; %time interval of solution x0=[0;0]; %initial conditions [t,x]=ode45( @resonance ,tspan,x0); %call to function and solve ode plot(t,x(:,1), '-k' ); %begin plotting grid; xlabel( 'Time (sec)'
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ); ylabel( 'Distance (m)' ); title( 'Forced Harmonic Oscillator at Resonance' ); function xdot = resonance(t,x) %RESONANCE - function containing ode of forced harmonic oscillator %at resonance. File written by S.C. Tegler. Last modified 3/3/2011. %----------------------------------------------------------------% wo=2*pi*5; %natural frequency w=2.0*pi*5; %forced frequency xdot=[x(2);-wo^2*x(1)+600*cos(w*t)]; %ode end end...
View Full Document

This note was uploaded on 02/23/2012 for the course PHYSICS 265 taught by Professor Tegler during the Spring '11 term at N. Arizona.

Ask a homework question - tutors are online