Changing fraction to decimal form

Hello,
I am trying to change my fractions to numbers, but when I use the eval() function, it won't do it
V = 50; % cm^3
R = .05; % ohms
Vj = 30; % cm^3
DeltaH = 15000; % J/C
C = 4000; % K
cp = 2.7778e-4; % Wh/g K
cp_f = 9.7694e-4; % Wh/g K
U = 12.5e-4; % W/cm^2 K
A = 30; % cm^2
rho = 1.8; % g/cm^3
rho_f = 1.07; % g/cm^3
syms T Tj I Fj Tj_in
x = [Tj T];
u = [I Fj Tj_in];
y = x;
f1 = Fj/Vj*(Tj_in-Tj)+(U*A/(rho_f*cp_f*Vj))*(T-Tj);
f2 = I^2*R/(rho*cp*V)+I*DeltaH*exp(-C/(273+T))-(U*A/(rho*cp*V))*(T-Tj);
dx = [f1; f2];
A = jacobian(dx,x);
B = jacobian(dx,u);
C = jacobian(y,x);
D = jacobian(y,u);
Then here is my output
eval(A)
ans =
[ - Fj/30 - 2692700942717151/2251799813685248, 2692700942717151/2251799813685248]
[ 62500/41667, (60000000*I*exp(-4000/(T + 273)))/(T + 273)^2 - 62500/41667]
But I want these as numbers with decimals if possible! I wonder why eval() isn't working

 Respuesta aceptada

Star Strider
Star Strider el 5 de Oct. de 2015

9 votos

Since your expressions contain symbolic variables, use the vpa function. (For those that are purely numeric, double will also work.)

4 comentarios

Rick
Rick el 5 de Oct. de 2015
How can I cut off the decimal after a few decimal points?
Star Strider
Star Strider el 5 de Oct. de 2015
You can control the number of significant digits displayed with the second argument to vpa. It doesn’t offer the sort of floating point precision format options that (for instance) fprintf does.
Rick
Rick el 5 de Oct. de 2015
Okay, thank you!
Star Strider
Star Strider el 5 de Oct. de 2015
My pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Argument Definitions en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 5 de Oct. de 2015

Comentada:

el 5 de Oct. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by