Normalisation inside ODE function

3 views (last 30 days)
IISc
IISc on 19 Aug 2014
Dear All,
I have a issue descibed as follows
The following are the Euler integration equations in the original code inside a while loop
Var1 = Var1 + dVar1 * delt;
Var2 = Var2 + dVar2 * delt;
Vau3 = Var3 + dVar3 * delt;
Var4 = Var4 + dVar4 * delt;
tnor = sqrt(Var1*Var1 + Var2*Var2 + Vau3*Var3 + Var4*Var4);
Var1 = Var1 / tnor;
Var2 = Var2 / tnor;
Vau3 = Var3 / tnor;
Var4 = Var4 / tnor;
Iam reqriting using ODE method based code (in built matlab function). There seems to be issue the way normalisation of Var1, Var2, Var3, Var4 is to be done. If i do not do the normalisation the two codes match. (of the course the results will not be correct. The variables need to be normalised before next step of integration).
How should i implement the above last five lines so that when the solver evaluates the function in the next iteration it uses the normalised value for Var1, Var2, Var3 & Var4. Currently in ODEFUN i was doing this in beginning by writing
tnor = Y(1 )+ Y(2) + Y(3) + Y(4)
Y(1) = Y(1)/tnor
Y(2) = Y(2)/tnor
Y(3) = Y(3)/tnor
Y(4) = Y(4)/tnor
This does not work.
Regards,
Tarun Uppal

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!