I'm trying to use ODE45 to solve a system of nonlinear differential
equation with if condition
My problem is i want to record the function as well as the derivatives of the
original equation as well
I created two files one for the function and the other for ode45 solver
as follows:
myode_ex1 function:
function [dydt k] = myode_ex1(t, y)
% this functin are used to show the value of the passed out parameter of
ODE45
dydt=zeros(2,1);
ko%;co;mG;
if y(1)>0
k*sin(5*t); %external force
else k=5*sin(5*t);
end
dydt(1)=y(2);
dydt(2)=(1/m)*(k-ko*y(1)-co*y(2));
the main file:
clear;clc;
t=[0 0.35];yo=[1 2];
[T Y] = ode45(@myode_ex1, t, yo);
[dydt k] = myode_ex1(T, Y);
but i get an error message and not able to get the second line to be executed
There is a posting in Mathworks about how to record the drivative as well as a
function using ODE45 in this location:
http://www.mathworks.com/support/solutions/en/data/1-196SD/?solution=1-196SD,
but in this example, ODE solves a single linear equation
your suggestions, comments, and help are very appreciated and important to me
Regards
Hi, i need help in pass out extra parameters using ODE45 with a set of equation
Started by ●October 5, 2009