Error in ode45 “inputs must be floats, namely single or double” when solving rocket flight equation.
Im trying to solve a non-linear first order differential equation with ode45, with a weird function thrust_cont thats supposed to describe the thrust of a model rocket.
syms v(t) a(t) y(t) thrust_complete(t) t diff_equation(t,v) thrust_cont(t) thrust_cont(t)
thrust_clean = [0,0.176;0.001,0.198;0.002,0.381;0.003,0.414;0.004,0.176;0.005,0.104;0.006,0.27;0.007,0.17;0.008,0.201;0.009,0.107;0.01,0.248;0.011,0.159;0.012,0.1……..rest of the data; this is [time in ms, Force]
thrust_clean (1634:20000,:) = 0;
for n=1634:1:20000
thrust_clean (n:20000,1) = n/1000;
end
grad = 100;
cf = polyfit(thrust_clean(1:1700,1), thrust_clean(1:1700,2),grad);
thrust_complete = 0;
for g = 1:grad
thrust_complete = thrust_complete + cf(g)*t^(grad+1-g);
end
thrust_cont = heaviside(t) * thrust_complete * heaviside(1.633-t);
fplot(thrust_cont, [0,2])
m = 0.14;
C_probar = 2.3;
rho = 1.29;
A = pi*0.05*0.05;
C_d = 0.75;
span = [0,20];
diff_equation = thrust_cont/m – 9.8 -((C_d*rho*A*C_probar/(m*2))*(v(t)^2));
[t, flight] = ode45(@(t,v) diff_equation, span, 0)
in the bold highlighted line i have my final version of the continous thrust curve function, which i had to manipulate quite a bit (cause im not very good at matlab unfortunately). Then i define a couple of normal variables, and then the problem, i define my equation (which the right hand side is equal to the derivative of v), and I try to use the ode45 function, only for it to return the following error message:
Error using superiorfloat
Inputs must be floats, namely single or double.
Error in odearguments (line 114)
dataType = superiorfloat(t0,y0,f0);
Error in ode45 (line 107)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in TBD_matlab (line 23)
[t, flight] = ode45(@(t,v) diff_equation, span, 0)
I don’t even understand what the error is referring to or even trying to tell me, and I’ve been trying for quite some time now to move things around but nothing seems to work. I previously actually had tried to use dsolve to get an answer, but it found no analytical solution. If anybody has the slightest idea what could be happening i’d be grateful đź‘ŤIm trying to solve a non-linear first order differential equation with ode45, with a weird function thrust_cont thats supposed to describe the thrust of a model rocket.
syms v(t) a(t) y(t) thrust_complete(t) t diff_equation(t,v) thrust_cont(t) thrust_cont(t)
thrust_clean = [0,0.176;0.001,0.198;0.002,0.381;0.003,0.414;0.004,0.176;0.005,0.104;0.006,0.27;0.007,0.17;0.008,0.201;0.009,0.107;0.01,0.248;0.011,0.159;0.012,0.1……..rest of the data; this is [time in ms, Force]
thrust_clean (1634:20000,:) = 0;
for n=1634:1:20000
thrust_clean (n:20000,1) = n/1000;
end
grad = 100;
cf = polyfit(thrust_clean(1:1700,1), thrust_clean(1:1700,2),grad);
thrust_complete = 0;
for g = 1:grad
thrust_complete = thrust_complete + cf(g)*t^(grad+1-g);
end
thrust_cont = heaviside(t) * thrust_complete * heaviside(1.633-t);
fplot(thrust_cont, [0,2])
m = 0.14;
C_probar = 2.3;
rho = 1.29;
A = pi*0.05*0.05;
C_d = 0.75;
span = [0,20];
diff_equation = thrust_cont/m – 9.8 -((C_d*rho*A*C_probar/(m*2))*(v(t)^2));
[t, flight] = ode45(@(t,v) diff_equation, span, 0)
in the bold highlighted line i have my final version of the continous thrust curve function, which i had to manipulate quite a bit (cause im not very good at matlab unfortunately). Then i define a couple of normal variables, and then the problem, i define my equation (which the right hand side is equal to the derivative of v), and I try to use the ode45 function, only for it to return the following error message:
Error using superiorfloat
Inputs must be floats, namely single or double.
Error in odearguments (line 114)
dataType = superiorfloat(t0,y0,f0);
Error in ode45 (line 107)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in TBD_matlab (line 23)
[t, flight] = ode45(@(t,v) diff_equation, span, 0)
I don’t even understand what the error is referring to or even trying to tell me, and I’ve been trying for quite some time now to move things around but nothing seems to work. I previously actually had tried to use dsolve to get an answer, but it found no analytical solution. If anybody has the slightest idea what could be happening i’d be grateful đź‘ŤÂ Im trying to solve a non-linear first order differential equation with ode45, with a weird function thrust_cont thats supposed to describe the thrust of a model rocket.
syms v(t) a(t) y(t) thrust_complete(t) t diff_equation(t,v) thrust_cont(t) thrust_cont(t)
thrust_clean = [0,0.176;0.001,0.198;0.002,0.381;0.003,0.414;0.004,0.176;0.005,0.104;0.006,0.27;0.007,0.17;0.008,0.201;0.009,0.107;0.01,0.248;0.011,0.159;0.012,0.1……..rest of the data; this is [time in ms, Force]
thrust_clean (1634:20000,:) = 0;
for n=1634:1:20000
thrust_clean (n:20000,1) = n/1000;
end
grad = 100;
cf = polyfit(thrust_clean(1:1700,1), thrust_clean(1:1700,2),grad);
thrust_complete = 0;
for g = 1:grad
thrust_complete = thrust_complete + cf(g)*t^(grad+1-g);
end
thrust_cont = heaviside(t) * thrust_complete * heaviside(1.633-t);
fplot(thrust_cont, [0,2])
m = 0.14;
C_probar = 2.3;
rho = 1.29;
A = pi*0.05*0.05;
C_d = 0.75;
span = [0,20];
diff_equation = thrust_cont/m – 9.8 -((C_d*rho*A*C_probar/(m*2))*(v(t)^2));
[t, flight] = ode45(@(t,v) diff_equation, span, 0)
in the bold highlighted line i have my final version of the continous thrust curve function, which i had to manipulate quite a bit (cause im not very good at matlab unfortunately). Then i define a couple of normal variables, and then the problem, i define my equation (which the right hand side is equal to the derivative of v), and I try to use the ode45 function, only for it to return the following error message:
Error using superiorfloat
Inputs must be floats, namely single or double.
Error in odearguments (line 114)
dataType = superiorfloat(t0,y0,f0);
Error in ode45 (line 107)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in TBD_matlab (line 23)
[t, flight] = ode45(@(t,v) diff_equation, span, 0)
I don’t even understand what the error is referring to or even trying to tell me, and I’ve been trying for quite some time now to move things around but nothing seems to work. I previously actually had tried to use dsolve to get an answer, but it found no analytical solution. If anybody has the slightest idea what could be happening i’d be grateful đź‘ŤÂ ode45, matlab, differential equations MATLAB Answers — New Questions
​