I have a file that uses ODE45. The options and function call both reference seperate script (.m) files. I want to include them all into one large file. How do I do this? I want to include it all into a GUI without having to use any reference files.
2 views (last 30 days)
Show older comments
options = odeset('Events',@takeoff_event2, 'RelTol', 1e-6);
%states are [x v ]
state0= [0 1.2]; %initial condition
%integrate ode's 10
%ode=@(t,state) inrun2(t,state);
[ti,statei,tei,yei,iei]=ode45(@inrun2,tspan,state0,options);
And here are the seperate .m files
takeoff_event2.m
function [value,isterminal,direction] = takeoff_event2(t,state)
global xInrun xExtInrun ext
x=state(1);
% xInrun(end)-2 is the actual xInrun end-- extra added in plot_inrun
xTo=xInrun(end)-ext; % xTo = x takeoff (m)
value(1)=x-xTo;
%xxTovalue=[x xTo value]
isterminal(1)=1;
direction(1)=1;
%pause
return
inrun2.m
function [ statedot ] = inrun2(t,state)
% ODEs for inrun acceleration
% state vector = [ x v ]
global xInrun yInrun dydxInrun kurvature
global m CdA mu eta g
x=state(1); % x = horizantal coordinate
v=state(2);% v = velocity along path
dydx=interp1(xInrun,dydxInrun,x);% finding dydx for any value of x
k=interp1(xInrun,kurvature,x);% finding curvature for any value of x
theta=atan(dydx);% angle of slope at any value of x
statedot=[0 0]';% setting initial value of statedot
statedot(1)=v*cos(theta);
N=m*(g*cos(theta)+k*v*v);% normal force
statedot(2)=-g*sin(theta)-eta*v*v-mu*N*sign(v)/m;
%txvstatedot=[t x v statedot']
%pause
end
0 Comments
Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!