how to find input value of a function knowing one of the outputs?
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone!
i've got a matlab function defined as
[Q_hw,GUE,COP]=getGUE(T_hwi,T_set,T_ext,Q_gas)
What i need to do now is to find the correct Q_gas so that Q_hw is equal to a set value (let's say equale to 5). I assume to know T_hwi,T_set,T_ext and the set value of the output Q_hw but i have no info about GUE,COP.
Can anyone help me?
Thank you!
FP
0 个评论
采纳的回答
dpb
2019-3-4
Q_Htgt=5; % the target solution value
fnQ=@(QG) getGUE(T_hwi,T_set,T_ext,QG)-Q_Htgt; % define solver function
Q_guess = YourStartGuessValue; % need a starting value in neighborhood
Q=fzer0(@fnQ,Q_guess); % see if can find a zero
[~,GUE_tgt,COP_tgt]=getGUE(T_hwi,T_set,T_ext,Q); % solve for other values given the zero
NB: The values of the other arguments to getGUE and the target Q_H values are embedded in the anonymous function definition for fnQ; if you need to solve for another set of parameters or target value, those values must be redefined and then the definition of the anonymous function re-executed to make it reflect the changes.
See doc fzero for more details, examples with alternate ways to handle extra parameters.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!