how to find unknown within equation having unknown
7 次查看(过去 30 天)
显示 更早的评论
I have a equation which includes 2 matrix and 1 unknown I want to calculate the unknown for each row and save the results as another matrix for each term my equation is R/X=( 0.8*log(L*X/10e-06)+33 )
R is 132x1 matrix (known)
L is 132x1 matrix (known)
I want to find X matrix
0 个评论
回答(2 个)
Star Strider
2021-12-22
I have no idea if this actually has a robust (and mathematically correct) solution.
It is always appropriate to experiment, so I am doing that here —
RLX_fcn = @(X,R,L) R./X - ( 0.8*log(L.*X/10e-06)+33 )
R = randn(10,1);
L = randn(10,1);
X0 = rand(size(R))
[Xv,fv] = fsolve(@(X)RLX_fcn(X,R,L), X0)
Experiment further with the correct vectors.
.
1 个评论
John D'Errico
2021-12-22
编辑:John D'Errico
2021-12-22
Actually, no that is not correct, and it has an analytical solution, in terms of the wrightOmega function. It is sort of a cousin to the Lambert W, and probably about as well known.
John D'Errico
2021-12-22
编辑:John D'Errico
2021-12-22
R and L are known, with X being an unknown.
syms X L R
Xsol = solve(R/X==( 0.8*log(L*X/10e-06)+33),X)
The script w there is the wrightOmega function in MATLAB. Most people don't seem to know it even exists, but it does, as a special function, essentially to solve this exact class of problem..
help wrightOmega
So now you can form the solution simply enough, as...
Xfun = matlabFunction(Xsol)
So Xfun is a function of two variables, L and R. We can use this as follows:
Xfun(1,3)
If L and R are vectors, it will still work.
Xfun([1 2 3],[4 5 6])
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!