0

Hy

I have a column vector called theRas. It represents the Reduced Adjoint system in an Optimal Control problem. It is a [10 * 1] Column vector. It is of the form theRas(z1, z2, z3, z4, z5, lam1, lam2, lam3, lam4, lam5) =......

It is basically 10 SYMBOLIC differential equation in the form

z1dot = ... z2dot = ... . . lam5dot = ...

It is really large that's why I'm trying to explain it rather than just post it.

So now Iv not the initial values of all 10 variables and I want to solve it using ode45. This is the function where I'm trying to do that:

function [errorP] = p(lamda1,lamda2,lamda3,lamda4,lamda5)
initValues = [0 0 0 0 0 lamda1 lamda2 lamda3 lamda4 lamda5] 


theRas = ras()

[t,xa] = ode45(theRas,[0 3.14],initValues) %this does not work

m = size(t)

z1final = z1(t)
z2final = z2(t)
z3final = z3(t)
z4final = z4(t)
z5final = z5(t)

errorP = (3.14-z1final).^2 + (0-z2final).^2 + (0-z3final).^2 + (0-z4final).^2 + (0-z5final).^2

It gives me the error:

Error in MuPAD command: The operand is invalid. [_mult]

I have a feeling the way I'm defining my function in ode45 is wrong but I don't know how to fix it. Any help would be appreciated.

Sedzani
  • 1
  • 1
  • 2
    Don't use symbolic math inside of your integration function. Even if you get it to work, it'll be painfully slow (if it even finishes). Maybe have a look at [this blog post](http://blogs.mathworks.com/loren/2013/06/10/from-symbolic-differential-equations-to-their-numeric-solution/). – horchler Apr 07 '16 at 20:56
  • Thank you for the reference. I understand the method used there. I see he makes an example with one DE. I just want to ask whether the syntax would remain the same for a system of 10 DE's as i have? Also, my system as it is in matlab only represents the right side of the DE's; that is to say; the `diff(z(i)) where i=1 to 5` and `diff(lam(i)) where i = 1 to 5` is not shown in the equations. Will this change the approach required? – Sedzani Apr 08 '16 at 06:27

0 Answers0