I need to solve this system of differential equations.
I tested it with removing rk(3)
from the rk(2)
equation and in that case I do get some solution. The code runs without error. However when I keep the rk(3)
in the rk(2)
equation I get a bunch of errors.
function rk = odes(t,y)
sigma1=sqrt(10e5);
sigma2=0.1;
sigma0=10e5;
m=1;k=2;vb=0.1;mis=0.15;mik=0.1;g=9.81;Fn=m*g;Fs=mis*Fn;Fc=mik*Fn;vs=0.001
rk(1)=y(2);
rk(2)=1/m*(sigma1*rk(3)+sigma0*y(3)+sigma2*vb-y(2)*(k+sigma2));
rk(3)=(vb-y(2))-((sigma0*(vb-y(2)))/(Fc+(Fs-Fc)*exp(-((vb-y(2)/vs)^2))));
rk=rk(:);
end
clc
close all
clear all
timerange=[0 20]
IC=[0.1;0;0.1]
[t,y]=ode45(@(t,y) odes(t,y),timerange,IC)
figure
plot(t,y(:,1));
rk(3)
beforerk(2)
. It should not be necessary, but you can also insert a dummy declarationrk(2)=0
, thenrk(3)=...
, then the proper assignment ofrk(2)
.IC
vector (IC= [0.1,0.1,0]
)ode45
solver. You can either changetimerange
to a time vector at which you want the solution, or interpolatet
andy
yourself after integration with a time vector of your choice.