Error using odearguments, Inputs must be floats, namely single or double ?? ODE15s
Afficher commentaires plus anciens
Hi, I'm plotting a graph which involve differencial equation at which i'm using ODE15s to solve it.
But no matter how I check, i couldn't find any errors.
Can someone help me?
Here is my code
The main files
alpha = 1000; % Solution density correlation parameter (kg/m^3)
beta = 1100; % Solution density correlation parameter (kg/m^3)
H1 = 3; % Total tank height (m)
H2 = 2; % Height of top zone of tank (m)
L = 3; % Tank width (and length) (m)
CV = 0.256; % Outlet valve coefficient ((m^3/s)/(kPa/(kg/m^3))^0.5)
deltaP = 300; % Pressure drop over control valve (kPa)
Bc = 0.5; % Controller bias (-);
Kc = -5; % Controller gain (-)
taus = 10; % Level sensor time constant (s)
Ga = 1; % Actuator gain (-)
taua = 20; % Actuator time constant (s)
xia = 0.8; % Actuator damping factor (-)
tf = 2400; % Final simulation time (s)
MW0 = 16750; % Initial mass of water in tank (kg)
MB0 = 7150; % Initial mass of boganite in tank (kg)
hs0 = 2.5; % Initial level sensor reading (m)
w0 = 0; % Initial scaled valve stem velocity (1/s)
S0 = 0.5; % Initial dimensionless valve position (-)
%
% Pack the Parameters into single Pack
p = {alpha, beta, H1, H2, L, CV, deltaP, Bc, Kc, taus, Ga, taua, xia};
% Pack up the initial conditions
y0 = [MW0 MB0 hs0 w0 S0];
tspan = [0 tf];
[t,y] = ode15s(@(t,y) mass(t,y,p), tspan, y0);
and another files
mass.m which is my function files
function dmdt=mass(t,y,p)
% Function of dM/dt, solving change of total mass over changing
% time
% Unpacking the initial condition to local state variable m from
% bogvars.m
MW = y(1);
MB = y(2);
hs = y(3);
w = y(4);
S = y(5);
% Unpacking the parameters from bogvars.m
[alpha, beta, H1, H2, L, CV, deltaP, Bc, Kc, taus, Ga, taua, xia]=p{:};
% Retriving all the current value at time t using the function given
[QLi,CBLi,mdotBSi,hSP] = bogctrl(t);
% Algebraic equations
Mt = MW + MB; % eqn (14)
xBLo = MB/Mt; % eqn (11)
rhoLo = alpha + beta*(xBLo); % eqn (10)
hSPp = hSP/H1; % eqn (21)
htp = hs/H1; % eqn (20)
Vbot = 0.5*(H1+H2)*L^2; % eqn (16)
VT = Mt/rhoLo; % eqn (15)
mdotBLi = QLi*CBLi; % eqn (3)
sigma = hSPp - htp; % eqn (22)
Vtop = VT - Vbot; % eqn (17)
QLo = CV*S*(deltaP/rhoLo)^(0.5); % eqn (26)
mdotLo = rhoLo*QLo; % eqn (13)
xWLo = 1 - xBLo; % eqn (12)
syms mdotLi rhoLi xBLi positive
eq1 = (rhoLi*QLi)==mdotLi;
eq2 = alpha + beta*xBLi==rhoLi;
eq3 = xBLi*mdotLi==mdotBLi;
sol=solve(eq1,eq2,eq3,mdotLi,rhoLi,xBLi);
sol.mdotLi
sol.rhoLi
sol.xBLi
double(sol.mdotLi)
double(sol.rhoLi)
double(sol.xBLi)
Oc = Bc + Kc*sigma; % eqn (23)
h = H1-H2+(Vtop/L^2); % eqn (18)
mdotBLo = xBLo*mdotLo; % eqn (9)
mdotWLo = xWLo*mdotLo; % eqn (8)
mdotWLi = mdotLi - mdotBLi; % eqn (7)
% Evaluate the derivative of dMw/dt
dMWdt = mdotWLi-mdotWLo; % eqn (1)
dMBdt = mdotBLi + mdotBSi - mdotBLo; % eqn (2)
dhsdt = (h-hs)/taus; % eqn (19)
dwdt = ((Ga*Oc-S)/taua^2)-(2*(xia/taua)*w); % eqn (24)
dSdt = w; % eqn (25)
dmdt = [dMWdt dMBdt dhsdt dwdt dSdt]';
end
the errors are here
Error using odearguments (line 110)
Inputs must be floats, namely single or double.
Error in ode15s (line 148)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in bogvars (line 34)
[t,y] = ode15s(@(t,y) mass(t,y,p), tspan, y0);
And the file which calculate the flow,
function [QLi,CBLi,mdotBSi,hSP] = bogctrl(t)
% BOGCTRL: Dynamic inlet conditions and level setpoint for solubilisation
% tank model
%
% Input variable:
% t Current time (s)
% Output variables:
% QLi Inlet liquor volumetric flowrate (m^3/s)
% CBLi Inlet boganite concentration in liquor (kg/m^3)
% mdotBSi Inlet mass flowrate of solid boganite (kg/s)
% hSP Level control set-point (m)
% Inlet liquor conditions remain fixed for the duration of the simulation
QLi = 0.0565;
CBLi = 43;
% Introduce step change in level set-point at t = 5 minutes
if t < 300
hSP = 2.5;
else
hSP = 2.2;
end
% Introduce step change in solids stream feed rate at t = 20 minutes
if t < 1200
mdotBSi = 21.5;
else
mdotBSi = 21.5*0.7;
end
Appreciate any help :)
4 commentaires
Walter Roberson
le 8 Mai 2016
The // tells us that you are not using MATLAB. You might be using Octave. On the other hand, Octave does not support symbolic expressions, so it is a mystery as to which language you are using.
Rain
le 8 Mai 2016
Walter Roberson
le 9 Mai 2016
Eddy Tan:
This is not a private programming service. The volunteers answers questions here under the condition that the question and answer remain public for everyone to learn from. If your code was confidential you should never have posted it: you should have hired a consultant. If your code was not confidential, you should restore it to the posting.
Walter Roberson
le 9 Mai 2016
Rain flagged,
"Edited out due to copyright reason. But the problem and solutions remain in the thread. Please closed this thread."
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 9 Mai 2016
0 votes
Rain, there has to be really extraordinary reasons for us to close a Question that has suitable Answers. For example, we did delete one case where someone was asking for answers to the exam they were in the middle of writing.
Every piece of code that is "sufficiently novel" is automatically copyrighted by the author (at least in any country which is a signature to the Berne Convention on Copyright), so we do not close questions just because they contain copyrighted code. Especially since most countries have "fair use" / "fair dealings" exemptions for "analysis and critique", which certainly was being done here.
If the material was Confidential or Trade Secret, then, in law, it lost that status as soon as it was posted in public. It may have been deleted here, but there are an unknown number of copies of it on the 'net. It should be presumed that it escaped.
We very much discourage people deleting postings after they have been answered. This is a free service where the Questions are answered by volunteers who give their efforts as a public service. What we "charge" for it is that the discussion is public. If there are confidentiality concerns then there are people who can be hired. The discussion and effort was not a gift to you alone: it was a gift to everyone.
Catégories
En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!