MATLAB outputs fractions instead of float values

25 views (last 30 days)
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 =

Accepted Answer

Walter Roberson
Walter Roberson on 27 Sep 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))

More Answers (0)

Categories

Find more on Function Creation in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!