Borrar filtros
Borrar filtros

Using fsolve to find S. S is a function of (Cts,R,d,v,w,Q,W,D,S0) however Cts is a function of S.

1 visualización (últimos 30 días)
I have the following code and it runs fine but it doesn't give me the answer I'm looking for. If I change the value of S0 it gives me a different answer which it shouldn't as far as I'm aware. So I'm not sure what is wrong with it.
function S = MyReverseEquation3(Cts,R,d,v,w,Q,W,D,S0)
V=Q/(W*D);
Us=(9.81*R*S0)^0.5;
if ((Us*d/v)>1.2) && ((Us*d/v)<70);
Vcr=w*((2.5/(log10(Us*d/v)-0.06))+0.66);
else
Vcr=w*2.05;
I = 5.435-0.286*log10(w*d/v)-0.457*log10(Us/w);
J = 1.799-0.409*log10(w*d/v)-0.314*log10(Us/w);
f=@(S)(((w/(V-Vcr))*(Cts/(10^I))^(1/J))-S);
S = fsolve(f,S0);
end
end
My input is: Cts=90; R=0.33333; d=2*10^-3; v=1.6*10^-6; w = 1.9*10^-1; Q=2; W=1; D=1; S0 = 0.1 S = MyReverseEquation3(Cts,R,d,v,w,Q,W,D,S0)
S0 is my inital guess. I am trying to find a value of S which satisfies the equation.

Respuestas (2)

Walter Roberson
Walter Roberson el 9 de Mzo. de 2011
I'm having difficulty figuring out why you think changing S0 would not change the answer. For one thing, you can change S0 arbitrarily to make "Us" fall in to the magic range or not and thus be solved directly or via solve().

Jason
Jason el 9 de Mzo. de 2011
Ahh I see my misconception. I only iterated for one value of S0. I want to get a value of S so that when I sub it back into the equation I will get the same value of Cts as inputed before. Is it possible to iterate for more values and get the value I need?
  1 comentario
Walter Roberson
Walter Roberson el 9 de Mzo. de 2011
Do you mean sub S0 back in to the forward equation? If so, how far are you off now? Generally speaking, floating point limitations will keep you from getting an exact reverse value, but if you change S0 by eps(S0) positive and negative, then you should bracket the original Cts. How wide the bracketing will be will depend upon precision limitations.

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by