Need some help using solve

Hello everybody,
I'm facing some troubles trying to use the solve function. I'm getting the wrong value. I did all the calculations on paper and I'm getting a different answer.
So, here is my code:
a1 = 2.3; % cm cubicos
a2 = 2.3; % cm cubicos
a3 = 2.3; % cm cubicos
a4 = 2.3; % cm cubicos
A1 = 730; % cm cubicos
A2 = 730; % cm cubicos
A3 = 730; % cm cubicos
A4 = 730; % cm cubicos
v1 = 0.6; % 60% = 60/100 = 0.6
v2 = 0.6; % 60% = 60/100 = 0.6
k1 = 5.51; % cm cubicos / segundo
k2 = 6.58; % cm cubicos / segundo
g = 981; % cm / segundo ao quadrado
gama1 = 0.333;
gama2 = 0.307;
gama3 = 0.333; % gama3 = 1 - gama4
gama4 = 0.667; % gama4 = 1 - gama1
syms h4;
rh4 = solve((-a4/A4)*(2*g*h4)^(0.5) + ((gama4*k1)/A4)*v1, h4);
disp(h4);
So, if you do the math on paper, you expect to find h4 = 0.000468492
But the matlab is giving me h4 = 17953715759368072310851915890294825625/38322307732477017073753209451412474298368
So, does anyone know what is going on?

Respuestas (2)

Walter Roberson
Walter Roberson el 12 de Feb. de 2013

0 votos

By default, MuPAD converts all numeric values to rationals. You have been given the rational solution to your solve(). IF you want to see the floating point solution, then use double(h4)
Jacques Vernin
Jacques Vernin el 13 de Feb. de 2013

0 votos

Is it in MuPad? In MuPad notebook:
a1 := 2.3 ;
a2 := 2.3;
a3 := 2.3;
a4 := 2.3;
A1 := 730;
A2 := 730;
A3 := 730; A4 := 730;
v1 := 0.6;
v2 := 0.6;
k1 := 5.51;
k2 := 6.58;
g := 981;
gama1 := 0.333:
gama2 := 0.307:
gama3 := 0.333;
gama4 := 0.667;
rh4 := solve((-a4/A4)*(2*g*h4)^(0.5) + ((gama4*k1)/A4)*v1, h4): print(rh4):
rh5:= solve(-a4/A4*sqrt(2*g*h)+gama4*k1*v1/A4,h): print(rh5):
rh6:= 1/(2*g)*(gama4*k1*v1/a4)^2: print(rh6)
rh4 is yours, rh5 is the same, simpler, rh6 is the explicit solution. All are 0.000468492

Productos

Etiquetas

Preguntada:

el 12 de Feb. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by