MATLAB outputs fractions instead of float values

38 visualizaciones (últimos 30 días)
Jonathan Rabe
Jonathan Rabe el 27 de Sept. de 2019
Comentada: Jonathan Rabe el 27 de Sept. de 2019
Good day,
So I am trying to calculate the values from a few linear equations. The code works (I think it does but can't justify my answers yet because of this) but the output is in huge fractions. I would like to submit a pdf document but i want the outputs to be readable. Please help. Example code below:
syms x y z; %x = Ie, y = Ib, z = Vce
eqn1 = -x + y.*(BF+1) + z*(0) == 0;
eqn2 = x*(Re) + y*(REQ) + z*(0) == VEQ + VBE;
eqn3 = x*(Re) + y*(Rc*BF) + z*(1) == Vcc;
[A,B] = equationsToMatrix([eqn1, eqn2, eqn3], [x, y, z]);
X = linsolve(A, B);
format
X1 = X(1)
All the variables have been declared/calculated before this point. Example output:
X1 =

Respuesta aceptada

Walter Roberson
Walter Roberson el 27 de Sept. de 2019
This is correct. The Symbolic Toolbox is intended for situations where you want indefinitely precise closed-form answers, or at least indefinitely precise answers.
You can double() the answers. Or you can linsolve(double(A), double(B))

Más respuestas (0)

Categorías

Más información sobre Numbers and Precision 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