ode45_demo

ode45_demo - 1e-4,k1,k2,k3,m1,m2,b,omega>> plot(t,y shg...

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

View Full Document Right Arrow Icon
Bob’s Code from class April 6 and 8, 2010 Here are the matlab examples that I provided in class. Mass-Spring-Damper system from car, function: function dydt = spring_dydt(t,y, k1, k2, k3 ,m1, m2, b, omega) u = 0.00315 * cos(omega * t); dydt = [y(3); y(4); -(k1+k2)/m1 * y(1) + k2/m1 * y(2); k2/m2 * y(1) - (k2+k3)/m2 * y(2) - b/m2 * y(4) + k3/m2 * u ]; and calling statement: >> k1=1; k2=2; k3=3; m1=1;m2=1; b=1; omega=1; >> [t,y]= ode45(@spring_dydt,[0 100],[1;1;1;1]
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: * 1e-4,,k1,k2,k3,m1,m2,b,omega); >> plot(t,y); shg Population dynamics, function: function dydt = population_dydt(t,y) a=3.2; b=0.6; c=50; d=0.56; k=125; r=1.6; dydt =[r * y(1) * (1-y(1)/k)-a * y(1) * y(2)/(c+y(1)); b * a * y(1) * y(2)/(c+y(1))-d * y(2)]; and calling statement: >> [t,y]=ode45(@population_dydt,[1 100],[40; 40]); >> plot(t,y);shg...
View Full Document

This note was uploaded on 05/27/2010 for the course MAE MAE143B taught by Professor Prof.bitmead during the Spring '10 term at UCSD.

Ask a homework question - tutors are online