how to find unknown within equation having unknown
1 view (last 30 days)
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
Star Strider on 22 Dec 2021
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.
John D'Errico on 22 Dec 2021
Edited: John D'Errico on 22 Dec 2021
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..
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:
If L and R are vectors, it will still work.
Xfun([1 2 3],[4 5 6])