How can I call a function (with all its parameters) using another function?
10 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2013-3-5
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Manage Products 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!