From: trung trinh on
I have file root.m

function root
%Giai phuong trinh vi phan
tspan = [0 12];
x0 = [0 1]';
[t,x] = ode45(@ptvp, tspan, x0);
plot(t,x(:,1));
grid on;
%--------------------------------------------------------------------------
function xd = ptvp(t,q)
data;
xd = [q(2); h-q(1)*const^2];

and data.m

%data
syms x t;
a = sin(x);
h = int(a*sin(t),0,1);
const = 10;

and when type
>> root
??? Error using ==> odearguments
Inputs to odearguments must be floats, namely single or double.

Error in ==> odearguments at 137
dataType = superiorfloat(t0,y0,f0);

Error in ==> ode45 at 173
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...

Error in ==> root at 5
[t,x] = ode45(@ptvp, tspan, x0);

how to solve this eror
From: Steven Lord on

"trung trinh" <trungkstn(a)gmail.com> wrote in message
news:hq1ofn$i7f$1(a)fred.mathworks.com...
>I have file root.m
>
> function root
> %Giai phuong trinh vi phan
> tspan = [0 12];
> x0 = [0 1]';
> [t,x] = ode45(@ptvp, tspan, x0);
> plot(t,x(:,1));
> grid on;
> %--------------------------------------------------------------------------
> function xd = ptvp(t,q)
> data;
> xd = [q(2); h-q(1)*const^2];
>
> and data.m
>
> %data
> syms x t;
> a = sin(x);
> h = int(a*sin(t),0,1);
> const = 10;
>
> and when type
>>> root
> ??? Error using ==> odearguments
> Inputs to odearguments must be floats, namely single or double.

The function that you pass into the ODE solver must return a numeric value,
not a symbolic object. Add the following line at the end of your ptvp
function:

xd = double(xd);

You will likely also need to stop overwriting the value of t passed into
your function with the symbolic variable t on the first line of your data.m
script.

Alternately, if you want to solve this system of ODEs symbolically rather
than numerically, use DSOLVE.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: trung trinh on
thank for assistance. but calculate lost a lot of time. use a lot of RAM than normal manner