Error using fsolve (line 287) FSOLVE requires all values returned by functions to be of data type double.

조회 수: 1 (최근 30일)
I have faced with this error namely: FSOLVE requires all values returned by functions to be of data type double.
I write my code as follows:
[Te, Tfin, Tlin, Tc] = HeatPumpCoolingg(4 ,1 ,0.9 ,0.8, 93.28, 0.2, 70 ,7 ,1.15 ,1.14 ,12.54 ,12.53 );
function [Te, Tfin, Tlin, Tc] = HeatPumpCoolingg(Tfout, CW ,etam ,etai, r, C, Qu ...
,Tlout ,NTUe ,NTUc ,mg ,mu)
Tlin = (Qu / ( CW * mu )) + Tfout;
Tc = ((Tlout - Tlin) / (1 - exp(-NTUc))) + Tlin;
anonymf = @(x) Function(x, Tc ,Tfout, CW ,etam ,etai, r, C, Qu ,NTUe ,mg);
x = fsolve(anonymf,[1,1]);
Te = x(1);
Tfin = x(2);
end
function [F] = Function( x, Tc ,Tfout, CW ,etam ,etai, r, C, Qu ,NTUe ,mg)
etac = (Tc/(x(1) - Tc));
COPHP = ((etam * etai * (etac - C*x(1)/r))/(1 + 1/(2 *etac) ...
* C * x(1)/r) * (1/etac - 1));
F(1) = ((Tfout - x(2))/(Tfout - x(1))) - 1 + exp(-NTUe) == 0;
Qg = (CW * mg * (x(2) - Tfout));
F(2) = Qg - ((COPHP + 1)/COPHP) * Qu == 0;
end
Thank you in advance.

채택된 답변

Matt J
Matt J 2021년 4월 2일
편집: Matt J 2021년 4월 2일
Get rid of '==0'
F(1) = ((Tfout - x(2))/(Tfout - x(1))) - 1 + exp(-NTUe) ;
F(2) = Qg - ((COPHP + 1)/COPHP) * Qu;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Special Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by