help with equation substituting

hi i want to substitute in an equation that has 2 variables (q) and (pwf), given that the user has to input several values for (pwf) to substitute into the equation and solve for (q)
Thank you

 Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Mzo. de 2016
Example:
new_pwf = rand();
new_equation = subs(TheEquation, pwf, new_pwf);
sol = solve(new_equation, q)

4 comentarios

mohamed
mohamed el 10 de Mzo. de 2016
ok this is what i did
clc
clear
new_pwf=[0:500:2500]
new_equation=subs('q=((1-(0.2*(pwf/pr)))-(0.8*(pwf/pr)^2))*(1067)',pwf,new_pwf);
sol=solve(new_equation,q)
but it gave me an error
Undefined function or variable 'pwf'.
Error in Untitled2 (line 4) new_equation=subs('q=((1-(0.2*(pwf/pr)))-(0.8*(pwf/pr)^2))*(1067)',pwf,new_pwf);
syms pwf pr q
expression = ((1-(0.2*(pwf/pr)))-(0.8*(pwf/pr)^2))*(1067);
new_expression = subs(expression, pfw, 0:500:2500);
There is no point solving for a variable (q) that appears isolated on one side of a comparison.
Solving a vector of expressions can only work when the number of elements in the vector is the same as the number of variables indicated to solve for. With 5 values for the new pwf you would need to be solving for 5 variables.
mohamed
mohamed el 11 de Mzo. de 2016
Editada: mohamed el 11 de Mzo. de 2016
ty very much you really helped me if i may ask another question whne i substitute into an equation this is the result
q =
1.0e+03 *
1.0670 0.9902 0.8451 0.6317 0.3500 0
i need the results to be
1067 990 845 632 350 0 i dont want them multiplyed by 1.0e+03 and i tried the double() code and it didnt work thank you
Walter Roberson
Walter Roberson el 12 de Mzo. de 2016
format long g

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 10 de Mzo. de 2016

Comentada:

el 12 de Mzo. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by