MATLAB outputs fractions instead of float values

26 次查看(过去 30 天)
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 =

采纳的回答

Walter Roberson
Walter Roberson 2019-9-27
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))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Function Creation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by