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

조회 수: 2 (최근 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 !

채택된 답변

Walter Roberson
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개)

카테고리

Help CenterFile Exchange에서 Manage Products에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by