how to find unknown within equation having unknown
    5 views (last 30 days)
  
       Show older comments
    
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 Comments
Answers (2)
  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.  
.
1 Comment
  John D'Errico
      
      
 on 22 Dec 2021
				
      Edited: John D'Errico
      
      
 on 22 Dec 2021
  
			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
      
      
 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..
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 Comments
See Also
Categories
				Find more on Matrix Indexing in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!