I have symbolic variables which are:
[q dq ddq n]
q=[q1; q2];
dq=[dq1; dq2];
ddq=[ddq1; ddq2];
and variable n is
n=[2*dq1 + (83*dq1*dq2)/400;
(83*dq1^2)/800 + 2*dq2]
I'm trying to obtain the values of an ODE function using the variables:
state=[q; dq];
u=[5;5];
q1=state(1);
q2=state(2);
dq1=state(3);
dq2=state(4);
dxdt1=dq1;
dxdt2=dq2;
ddxdt=inv(B)*(u-n); %which is 2x1 matrix
%B is a 2x2 numeric matrix
dstate=[dxdt1; dxdt2; ddxdt];
using this variables I try to obtain the solution of the equation
t0=0;
tf=1;
N=10;
tspan=linspace(t0,tf,N);
x0=[0.5; 0.5;zeros(2,1)];
function_q=@(tspan,state)ode_system(tspan,state,B,n,u);
where odesystem is
function dydt=ode_system(time, state,B,n_t,u)
q1=state(1);
q2=state(2);
dq1=state(3);
dq2=state(4);
dxdt1=dq1;
dxdt2=dq2;
ddxdt=inv(B)*(u-n_t);
dydt=[dxdt1; dxdt2; ddxdt]
end
at the end I try to calculate
[tout,xout]=ode45(function_q, tspan, x0)
when I run the code it gives an error and say
Error using odearguments (line 110) Inputs must be floats, namely single or double.
Error in ode45 (line 115) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in mainfunc (line 140) [tout,xout]=ode45(function_q, tspan, x0) try open('Error using odearguments (line 110) ↑ Error: String is not terminated properly.
I think the problem is resulted from to put symbolic variable to ode45 function. How can I solve this problem? How can I define n matrix in numerical form