Solving 7x7 Matrix Returns Very Long Fractions
Show older comments
Hello, I'm solving a 7x7 matrix. After inputting the A matrix and B vector and solving, the returned solutions for X are very, very long fractions. How can I specify that I would like these returned in rounded numbers (in scientific notation, for example), not in fractions? Code is below, and thank you.
Cx = 6 + 0.0806;
Cy = 6.8359;
syms w1 w2 w3 w4 w5 w6 w7;
eqn1 = + ((Cx)*w1) - (4*w2) + (1*w3) + (0*w4) + (0*w5) + (0*w6) - (4*w7) == (Cy)*(2*.125);
eqn2 = - (4*w1) + ((Cx)*w2) - (4*w3) + (1*w4) + (0*w5) + (0*w6) + (0*w7) == (Cy)*sin(2*pi*.250);
eqn3 = + (1*w1) - (4*w2) + ((Cx)*w3) - (4*w4) + (1*w5) + (0*w6) + (0*w7) == (Cy)*sin(2*pi*.375);
eqn4 = + (0*w1) + (1*w2) - (4*w3) + ((Cx)*w4) - (4*w5) + (1*w6) + (0*w7) == (Cy)*sin(2*pi*.500);
eqn5 = + (0*w1) + (0*w2) + (1*w3) - (4*w4) + ((Cx)*w5) - (4*w6) + (1*w7) == (Cy)*sin(2*pi*.625);
eqn6 = + (0*w1) + (0*w2) + (0*w3) + (1*w4) - (4*w5) + ((Cx)*w6) - (4*w7) == (Cy)*sin(2*pi*.750);
eqn7 = - (4*w1) + (0*w2) + (0*w3) + (0*w4) + (1*w5) - (4*w6) + ((Cx)*w7) == (Cy)*sin(2*pi*.875);
[A,B] = equationsToMatrix([eqn1, eqn2, eqn3, eqn4, eqn5, eqn6, eqn7], [w1, w2, w3, w4, w5, w6, w7]);
X = linsolve(A,B)
This returns the following (only w1 solution showing due to length):
X = 2182838934989084222859735148265186349320750668882016039009/735711874176482141060943596914818753670316261979795226624
Accepted Answer
More Answers (0)
Categories
Find more on Special Values in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!