Symbolic variables: Isolate a variable in an equation?
Mostrar comentarios más antiguos
I always have trouble isolating symbolic variables in equations. See this for example:
8*x1 + 2*x2 + 3*x3 - 51 = 0
want to isolate x1, manually know is this:
x1 = (51 - 2*x2 - 3*x3)/8
how can I do this in matlab? Thanks in advance.
Respuesta aceptada
Más respuestas (1)
Arash Moharjeri
el 10 de Nov. de 2017
Editada: Walter Roberson
el 10 de Nov. de 2017
Hi all,
I am trying to rearrange the below equation to solve for R0.

This is how I have written the equation in MATLAB.
syms R0 H hs K_h rw P
EQN= (H - power((power(hs,2))+((P/K_h)*((power(R0,2)*log(R0/rw))-(power(R0,2)-power(rw,2))*0.5)),0.5) == 0);
EQN2=isolate (EQN, R0)
When I run isolate, it doesn't give me an error but it doesn't give me a correct answer either. It gives me the original equation.
Can anyone assist me with this issue? Is it because the equation is too complicated to rearrange ?
Thanks
7 comentarios
Walter Roberson
el 10 de Nov. de 2017
The equation is too complicated for MATLAB to rearrange. The solution is
R0 = exp((1/2)*lambertw((2*H^2*K_h-2*K_h*hs^2-P*rw^2)/(P*rw^2*exp(1)))+1/2)*rw
Unfortunately even if you do a number of steps of simplification yourself, MATLAB struggles to find the lambertw solution.
andrea giovannini
el 4 de En. de 2018
Editada: andrea giovannini
el 4 de En. de 2018
Hello everyone, i'm new here. I have a problem equal to this. I have an equation and matlab can't isolate the variabile y. the equation is as follows:
syms B y s n u v Dc d
eq=(0==(B^(5/3)*y^(5/3)*s^(1/2)*(B+2*y)^(-2/3))/(n*B*(-(32)^(1/2))*u*log10((d/(12*y+12*Dc))+(0.222*v/(y*u+Dc*u))))-y+Dc);
isolate(eq,y)
I want to ask you, how did you find the solution for the Arash's equation? did you use another program?
I've tried to simplify the equation removing y from the numerator as follows
syms B y s n u v Dc d
eq=(0==(B^(5/3)*y^(5/3)*s^(1/2)*(B)^(-2/3))/(n*B*(-(32)^(1/2))*u*log10((d/(12*y+12*Dc))+(0.222*v/(y*u+Dc*u))))-y+Dc);
isolate(eq,y)
but it doesn't work. Thanks a lot.
Beautiful community
Walter Roberson
el 4 de En. de 2018
It is difficult to find solutions for that. Are there any assumptions that can be added? For example are all of the values non-negative?
andrea giovannini
el 5 de En. de 2018
Hi, thanks for the interest.
all the variables are non-negative values. y is the depth of a river, B is the average width of the channel ,Dc the scour depth, s is the slope. d is the particle size and n a coefficient that can assume only two different positive values. u is a positive coefficiente that depends from d. the only coefficient I can fix is v = 1.4e^-6.
Beyond this I can't say anything else. How can I put these information in the code? Do you think these can be useful? Thanks a lot for the your answer and rapidity, Walter.
Walter Roberson
el 5 de En. de 2018
I am not sure that it can be solved in closed form; it might have to be numeric.
You can get a starting approximation by taylor to order 4 and solve the resulting cubic for real solutions; I do not know how good of an approximation that would be.
What are some typical ranges for values? I can pick out some values from http://www.winnipeg.ca/WaterAndWaste/pdfs/dept/EA-CSIF/Appendix8-WaterQualandQuant.pdf but I worry that I might be inappropriately cherry-picking round numbers that do not reflect reality.
andrea giovannini
el 8 de En. de 2018
Hi, I can't say the ranges for the values, because I'm working to built a completely general Bayesian Network to estimate the scour depth. I'll try with the numerical method and see what happens. Thank a lot for your time and disponibility.
Walter Roberson
el 8 de En. de 2018
Estimating the scour depth given the depth of the river and the other aspects would be fairly different mathematically than attempting to find the depth of the river with that formula.
Dc = ((3*d*u+8*v)*exp(-RootOf(-2*n*Z*(72*exp(Z)*u*y-3*d*u-8*v)-9*y^(5/3)*sqrt(s)*sqrt(2)*(ln(2)+ln(5))*exp(Z),Z))-36*y*u)/(36*u)
where RootOf(-2*n*Z*(72*exp(Z)*u*y-3*d*u-8*v)-9*y^(5/3)*sqrt(s)*sqrt(2)*(ln(2)+ln(5))*exp(Z),Z) means the set of Z such that -2*n*Z*(72*exp(Z)*u*y-3*d*u-8*v)-9*y^(5/3)*sqrt(s)*sqrt(2)*(ln(2)+ln(5))*exp(Z) is 0 -- the roots of that expression.
That expression does not have a closed form solution, but it would be pretty tractable to solve numerically I think, whereas I think solving for y would be more difficult numerically.
Categorías
Más información sobre Common Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!