decay_onefunc - tspan =[0 25%time interval for solution[t,N...

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

View Full Document Right Arrow Icon
function [] = decay_onefunc(); %DECAY_ONEFUNC - A function that solves the differential %equation dN/dt = -lambda*N for N(t). %Function call on command line - decay_onefunc %Output - table of N vs. t to command window and plot of N vs. t %File written by S.C. Tegler. Last modified 3/8/11. %--------------------------------------------------- N0 = 100; %initial number of particles
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: tspan = [0 25]; %time interval for solution [t,N] = ode45( 'decay' ,tspan,N0); %call to solve the ode using R-K table = [t N] %table of N vs. t to command window plot(t,N); %begin plotting xlabel( 'Time (sec)' ); ylabel( 'N' ); title( 'Radioactive Decay' ); %end plotting function dNdt = decay(t,N) %sub-function containing ode dNdt = -0.2*N; 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