MATLAB: Im trying to solve an equation that have variable on left and right side

both side variable

How do I solve this equation? I'm giving the important information also.
depth= 1385.33
por=0.153
Qv=0.980
B=3200
Rw=0.265
m=1.86
n=2.2
Rt=4.05
Sw=(Rw/((por^m)*Rt*(1+(B*Qv*Rw)/Sw)))^(1/n)

Best Answer

How is depth relevant to anything here? It does not appear in the expression. Maybe I'm just not thinking very "deeply" today.
If Sw appears on both sides of the equality, surely you can subtract Sw? Just move everything to the same side. WTP?
por=0.153;
Qv=0.980;
B=3200;
Rw=0.265;
m=1.86;
n=2.2;
Rt=4.05;
fun = @(Sw) Sw - (Rw./((por^m)*Rt*(1+(B*Qv*Rw)./Sw))).^(1/n);
Note that for Sw <= 0, you either have a divide by zero at Sw == 0, or a complex result. So If any real solution exists, it must be for positive Sw.
Also note the use of ./ and .^ where necessary in fun. Does a solution exist? PLOT IT!
fplot(fun,[0,0.01])
yline(0);
It looks like a positive solution exists near 0.007.
[Swsol,fval] = fzero(fun,0.007)
Swsol =
0.00698017018548943
fval =
8.67361737988404e-19
We could also do this using symbolic tools. No analytical solution will exist because of the non-integer power.
syms Sw
vpasolve(fun(Sw))
ans =
0.006980170185489425081287353
No other positive root will exist. That should be not too difficult to prove.