How can I call a function (with all its parameters) using another function?
10 views (last 30 days)
Show older comments
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 !
0 Comments
Accepted Answer
Walter Roberson
on 5 Mar 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)
0 Comments
More Answers (0)
See Also
Categories
Find more on Manage Products in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!