MATLAB Answers

Error using odearguments (line 113) Inputs must be floats, namely single or double.

22 views (last 30 days)
Sumeet Sinha
Sumeet Sinha on 27 Feb 2021
Commented: Jan on 3 Mar 2021
code concerned is as below
%%
format long,qgin,c_g_in,c,c_l_in,vg,vl,m,ql,v_max,v,xp,yxco,yxh2,mu,kd,c0,c0g,ngout,qgout;
qgin=12.000;
c_g_in=[1.000 2.000 3.000 4.000 5.000 6.000 ];
c=zeros(13,1);
c_l_in=[1.000 3.000 5.000 7.000 3.000 5.000];
vg=27.000;
kla=[13.000 34.000 5.000 6.000 7.000 7.000 ];
vl=65.000;
m=[23.000 3.000 5.000 2.000 1.000 4.000];
ql=123.000;
v_max=[1.000 2.000 3.000 5.000 7.000 1.000];
for i=1:6
v(i)=-v_max(i).*c(i);
end
xp=45.000;
yxco=3.000;
yxh2=5.000;
mu=-v(1)*yxco-v(2)*yxh2;
kd=15.000;
c0=[1.000 2.000 3.000 0.000 0.000 0.000 0.000 0.000 0.000 2.000 5.000 6.000 13.000];
c0g=c0(1:6);
ngout=qgin*sum(c_g_in,'all')-kla(1)*((c(1)/m(1))-c(7))*vl-kla(2)*((c(2)/m(2))-c(8))*vl-kla(3)*((c(3)/m(3))-c(9))*vl+kla(4)*((c(10)/m(4))-c(4))*vl+kla(5)*((c(11)/m(5))-c(5))*vl+kla(6)*((c(12)/m(6))-c(6))*vl;
qgout=ngout*R*t/(sum((psat.*c0g),'all'));
f=@(t,c)[((qgin.*c_g_in(1)-qgout.*c(1))./vg)-kla(1).*(vl/vg).*((c(1)./m(1))-c(7)),
((qgin.*c_g_in(2)-qgout.*c(2))./vg)-kla(2).*(vl/vg).*((c(2)./m(2))-c(8)),
((qgin.*c_g_in(3)-qgout.*c(3))./vg)-kla(3).*(vl/vg).*((c(3)./m(3))-c(9)),
((qgin.*c_g_in(4)-qgout.*c(4))/vg)+kla(4).*(vl/vg).*((c(10)./m(4))-c(4)),
((qgin.*c_g_in(5)-qgout.*c(5))/vg)+kla(5).*(vl/vg).*((c(11)./m(5))-c(5)),
((qgin.*c_g_in(6)-qgout.*c(6))/vg)+kla(6).*(vl/vg).*((c(12)./m(6))-c(6)),
((ql/vl).*(c_l_in(1)-c(7))+kla(1).*((c(1)./m(1))-c(7))+v(1).*c(13)),
((ql/vl).*(c_l_in(2)-c(8))+kla(2).*((c(2)./m(2))-c(8))+v(2).*c(13)),
((ql/vl).*(c_l_in(3)-c(9))+kla(3).*((c(3)./m(3))-c(9))+v(3).*c(13)),
((ql/vl).*(c_l_in(4)-c(10))-kla(4).*((c(10)./m(4))-c(4))+v(4).*c(13)),
((ql/vl).*(c_l_in(5)-c(11))-kla(5).*((c(11)./m(5))-c(5))+v(5).*c(13)),
((ql/vl).*(c_l_in(6)-c(12))-kla(6).*((c(12)./m(6))-c(6))+v(6).*c(13)),
((ql/vl).*(-c(13).*xp)+mu.*c(13)-kd.*c(13))]
tspan=[0 600];
[t,c]=ode45(f,tspan,c0);
error is as follows
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 gshs (line 39)
[t,c]=ode45(f,tspan,c0);

Answers (1)

Jan
Jan on 27 Feb 2021
What is the purpose of this line:
format long,qgin,c_g_in,c,c_l_in,vg,vl,m,ql,v_max,v,xp,yxco,yxh2,mu,kd,c0,c0g,ngout,qgout;
It should fail, because these variables are not defined before.
When I run your code without this line, I get an error here:
qgout=ngout*R*t/(sum((psat.*c0g),'all'));
% Undefined function or variable 'R'.
I guess that you have defined these variables as symbolic.
  3 Comments
Jan
Jan on 3 Mar 2021
It is your turn to find out, which variables are no floats. I cannot guess this, but you can check this using the debugger.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!