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

采纳的回答

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 CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by