MATLAB: Error input must be floats, namely single or double. MATLABnumerical method tspan=[0:0.25:5]; syms x(t) m f_0 dx=diff(x) x0=0; ode=m*dx+k*x==f_0*sin(t) [t,x]=ode45(@(t,x) ode,tspan,x0) plot(t,x,'m') Best Answer Look at the documentation odeFunction for information on how to convert symbolic ode to numeric. Related SolutionsMATLAB: Anonymous function in ode45: column vector error You are not calling ‘xdot’ correctly in your ode45 call. Try this: t = 0:.01:20;x0 = [0 0]' + eps;xdot = @(t,x) [0 1; 0 0] * x;[T,X] = ode45(xdot,t,x0)figureplot(T, X)gridAlso, the result is uniformly zero, so to prevent that, I added eps to ‘x0’. MATLAB: Ode23s Inputs must be floats, namely single or double. Delete these two lines in your function and it works:syms x1 x2 x3 x4 x5 v1 v2 v3 v4 v5;x = [ x1 , x2 , x3 , x4 , x5 , v1 , v2 , v3 , v4 , v5]'; Related QuestionODE45 error Inputs must be floats, namely single or double.4th order Runge-Kutta code that can solve for several intial conditionsError using odearguments: nputs must be floats, namely single or double.
Best Answer