Error using odearguments (line 113),Error in ode45 (line 115)

I try to use the ode45 function:
syms t
M=diag([1 1 2]);
K=[18.463 -10.615 2.769;-10.615 10.154 -3.692;2.769 -3.692 1.615];
D=[0.1997 -0.0786 0.0125
-0.0786 0.1335 -0.0524
0.0125 -0.0524 0.0476];
A=[zeros(3) eye(3);-inv(M)*K -inv(M)*D];
t0=0;tf=30;
tspan=[t0 tf];
Y0=zeros(6,1);
[t,Y]=ode45(@func2,tspan,Y0);
I created the function:
function H=func2(t,Y)
A =[ 0 0 0 1.0000 0 0;0 0 0 0 1.0000 0;0 0 0 0 0 1.0000;
-18.4630 10.6150 -2.7690 -0.1997 0.0786 -0.0125;
10.6150 -10.1540 3.6920 0.0786 -0.1335 0.0524;
-1.3845 1.8460 -0.8075 -0.0063 0.0262 -0.0238];
syms q1 q2 q3 q4 q5 q6
syms T Po
Y=[q1; q2 ;q3; q4; q5; q6];
M=diag([1 1 2]);
T=11.607;
P=Po*mod(t/T,1);
F=[-P;0;P];
G=[0;0;0;inv(M)*F]
H=AA*Y+GG
end
And I then receive this error message:
Error using odearguments (line 113)
Inputs must be floats, namely single or double.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in Cauchy (line 15)
[t,Y]=ode45(@func2,tspan,Y0);
Any help would be greatly appreciated

Answers (1)

Torsten
Torsten on 15 Dec 2017
Edited: Torsten on 15 Dec 2017
ode45 is a numerical solver. So all variables supplied to ode45 in "Cauchy" and "func2" must be of type "single" or "double", not symbolic.
Best wishes
Torsten.

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 14 Dec 2017

Edited:

on 15 Dec 2017

Community Treasure Hunt

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

Start Hunting!