How can I call a function (with all its parameters) using another function?

2 visualizaciones (últimos 30 días)
I have defined the following function: (part of the code is omitted for simplicity)
function [t,y]= backEulerfedbatchSystem(rhs,drhs,x0,t0,tf,n)
In particular the parameter "rhs" is also a function defined by:
function dxdt = FedbatchFermenterModel(t,x,u,d,par)
When I call this function in this way:
backEulerfedbatchSystem(FedbatchFermenterModel,drhs,x0,t0,tf,n)
An error occurs. FedbatchFermenterModel cannot be computed because it lacks its parameters (t,x,u,d,par). How can I call the function FedbatchFermenterModel (with all its parameters) using backEulerfedbatchSystem? Any hint will be appreciated !

Respuesta aceptada

Walter Roberson
Walter Roberson el 5 de Mzo. de 2013
backEulerfedbatchSystem(@FedbatchFermenterModel, drhs, x0, t0, tf, n)
then inside the function,
rhs(t, x, u, d, par)
but you have to figure out u, d, par inside backEulerfedbatchSystem.
Are those parameters possibly known at the time backEulerfedbatchSystem is being called? If so, then
backEulerfedbatchSystem(@(t, x) FedbatchFermenterModel(t, x, u, d, par), drhs, x0, t0, tf, n)
and then inside the function,
rhs(t, x)

Más respuestas (0)

Categorías

Más información sobre Manage Products en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by