This is my main code:
y = [20 5 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];biopyrolysis = IdealGasMix('biomass_cell.xml');p = pressure(biopyrolysis);options = odeset('OutputFcn',{@odeplot,@odeprint});options = odeset(options,'RelTol',1.e-5,'AbsTol',1.e-9);tspan = [1 5];for nt = 1:20; out = ode15s(@reactor_ode,tspan,y,options,biopyrolysis);end
and these are my functions:
function dydt = reactor_ode(t,y,gas)[m,n] = size(y);dydt = zeros(m,n);for j = 1:n this_y = y(:,j); int_energy = this_y(1); vol = this_y(2); masses = this_y(3:end); % evaluate the total mass, and the specific internal energy and volume.
total_mass = sum(masses); u_mass = int_energy/total_mass; v_mass = vol/total_mass; % set the state of the gas by specifying (u,v,{Y_k})
setMassFractions(gas,masses); setState_UV(gas, [u_mass v_mass]); p = pressure(gas); % volume equation
vdt = feval(@vdot, t, vol, gas); % energy equation
a = feval(@area, t, vol); q = feval(@heatflux, t, gas); udt = -p * vdt + a * q; % species equations
ydt = total_mass * ydot(gas); % set up column vector for dydt
dydt(:,j) = [udt vdt ydt ]; endfunction q = heatflux(t, gas)q = 0.0; endfunction a = area(t,vol)a = 1.0;endfunction v = vdot(t, vol, gas)v = 1.e11 * (pressure(gas) - 101325.0); end
and the error I get is:
Error using fevalArgument must contain a string or function_handle.Error in ode15s (line 481) feval(outputFcn,[t tfinal],y(outputs),'init',outputArgs{:});Error in test (line 15) out = ode15s(@reactor_ode,tspan,y,options,biopyrolysis);
But the way I see, all the functions I am using are handle.
Best Answer