MATLAB: How to solve differential equations in matrix form

differential equationsdsolvematrix

my code is
syms vpex(t) vpey(t) vpez(t)
vpe = [vpex vpey vpez]';
eqn = diff(vpe) == fp-(2.*wpie+wpep).*vpe-gp;
C = vpe(0) == [0 0 0]';
[vpexSol(t), vpeySol(t), vpezSol(t)] = dsolve(eqn, C);
vpexSol(t) = simplify(vpexSol(t));
vpeySol(t) = simplify(vpeySol(t));
vpezSol(t) = simplify(vpezSol(t));
vpex = vpexSol(sec); vpey = vpeySol(sec); vpez = vpezSol(sec);
vpe = [vpex vpey vpez]';
but i got the error messages like that below. sym/subsindex (line 663) Invalid indexing or function definition. When defining a function, ensure that the body of the function is a SYM object. When indexing, the input must be numeric, logical or ':'.
how can i solve this problem?

Best Answer

[vpexSol, vpeySol, vpezSol] = dsolve(eqn, C);
vpexSol = simplify(vpexSol);
vpeySol = simplify(vpeySol);
vpezSol = simplify(vpezSol);
Related Question