How I solve a nonlinear equation with matlab function block?
Show older comments

Here is my blocks and 'Generator' matlab function block contents is
function StrongSolution = Generator(HotWater,WeakSolution, CoolingCapacity)
P = 4.82 % [kPa], Absolute Pressure
Cp = 4.2 % kJ/kgK
T_in = HotWater(1) % Celious
T_out = HotWater(2) % Celious
m_w = HotWater(3) % kg/s
T_w = WeakSolution(1) % Celious
x_w = WeakSolution(2)/100 % Nondimension
m_w = WeakSolution(3) * CoolingCapacity % kg/s
h_w = WeakSolution(4) % kJ/kg
WasteHeat = m_w*Cp*(T_in - T_out) % kJ
Tacc = 88
UA_G = 16.6*CoolingCapacity/(0.0986*exp(0.0254*Tacc))
T_lmG = WasteHeat/UA_G
fun = @(T_s) T_lmG - ((T_out-T_w)-(T_in-T_s))/log((T_out-T_w)/(T_in-T_s))
T_s = fzero(fun,[55 100])
StrongSolution = T_s
end
And I upload my problem.
I wanted to know 'T_s'. So I used 'fzero' function in a Matlab function block.
But the error was occured.

How can I solve the problem?
1 Comment
MinWoo Nam
on 4 Sep 2020
Accepted Answer
More Answers (0)
Categories
Find more on Simulink Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!