Currently I am using the ode45 solver, with my input parameters being a vector of length 7, which is two separate terms being length 6 and 1. My equations has a variable which needs to be solved for set amount of time and then it changes.
How do i go about doing this?
%so what im doing is,
tspan = [0 20];options = odeset('MaxStep',0.05,'RelTol',1e-8,'AbsTol',1e-9);stress1 = [525 450 385 200 150];stress2 = [630 560 475 332 200];for ii =1:length(stress1) % i intend to repeat this process for stress2
odeIp = [0 0 0 0 0 0 0 1 ii]';odeOp = ode45(@odefn,tspan,odeIp,options);Var2 = odeOp( : , 7); %gives me Solrequired
VarRequied(:,ii) = Var2;end%in the function im im using If statement to choose my initial conditions
function dOdeOp = odefn(t,odeIp)%input constants and splitting the terms
stress1 = [525 450 385 200 150];stress2 = [630 560 475 332 200];D0 = odeIp(7,1);alpha = odeIp(1:6);var = odeIp(8,1);sigvar = odeIp(9,1);if var ==1 mSig = 0;else mSig = 100;endif var ==1 aSig = stress1(sigvar);else aSig = stress2(sigvar);endequat = mSig + aSig*sin(omega*t);dequat = aSig*omega*cos(omega*t);%solve set of equations outputs Sol1,SolRequired
% solving a bunc of equtions to get Sol1 which is an array of 1x6 and SolRequired
% which makes up the 7 column
dOdeOp1 =[Sol1;SolRequired];dOdeOp2 = [dOdeOp1;var];dOdeOp = [dOdeOp2;sigvar];
currently only the last two coulmns of my output vector is obtaining values, which shouldnt be the case
Best Answer