how to find input value of a function knowing one of the outputs?

3 ビュー (過去 30 日間)
Fabio Pulcini
Fabio Pulcini 2019 年 3 月 4 日
回答済み: dpb 2019 年 3 月 4 日
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

採用された回答

dpb
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 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by