Finding x for y = f(x) in simulink

9 ビュー (過去 30 日間)
Phan Van Long
Phan Van Long 2022 年 1 月 18 日
回答済み: Dat Trương Lê Trí 2022 年 7 月 6 日
I have an equation which is uel = 3 + 3 * iel + 3 * log (3 * iel +1) a.k.a uel = f(iel) and I want to find iel ( uel is already known), so I have used fsolve to solve the problem in matlab and it works. Here is the code
---------------------------------------------------------------------
function iel = test(uel)
f = @(x) uel-(3 + 3 * x + 5 * log(3 * x + 1));
iel = fsolve(f,uel);
end
----------------------------------------------------------------------
But when i try to add this code into matlab function block in simulink, the model just don't run. I want my input to be uel and output to be iel. Can anyone please help me on this problem. Thank you so so much
  2 件のコメント
Max Heimann
Max Heimann 2022 年 1 月 18 日
Can you provide the error message?
Phan Van Long
Phan Van Long 2022 年 1 月 19 日
This is the error message sir @Max Heimann

サインインしてコメントする。

回答 (2 件)

Paul
Paul 2022 年 1 月 19 日
編集済み: Paul 2022 年 1 月 19 日
According to the Symbolic Math Toolbox, the solution can be expressed as
%iel = wrightOmega(uel/3 - log(3) - 2/3) - 1/3
assuming that iel and uel are real. If they can be complex, the expression for iel is the same, but there are some other conditions that have to be satisfied.
Check
%doc wrightOmega
for more info.
Check a couple of test cases (note that I changed the 5 to a 3 in the function test() to match the equation in the question)
uel = 0.3
uel = 0.3000
iel = test(uel)
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
iel = -0.1723
iel = wrightOmega(uel/3 - log(3) - 2/3) - 1/3
iel = -0.1723
uel = 5.4
uel = 5.4000
iel = test(uel)
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
iel = 0.2465
iel = wrightOmega(uel/3 - log(3) - 2/3) - 1/3
iel = 0.2465
function iel = test(uel)
% f = @(x) uel-(3 + 3 * x + 5 * log(3 * x + 1)); % doesn't match equation in Question
f = @(x) uel-(3 + 3 * x + 3 * log(3 * x + 1));
iel = fsolve(f,uel);
end

Dat Trương Lê Trí
Dat Trương Lê Trí 2022 年 7 月 6 日
Hi, I am facing the same problem, did you have any posible solution for this case?

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by