Matlab Outputting answers as fractions

111 visualizaciones (últimos 30 días)
Michael Finch
Michael Finch el 10 de Dic. de 2019
Comentada: Star Strider el 12 de Dic. de 2019
Hi so i'm trying to find 4 variables from 4 linear equations which it does however the answers output are all huge fractions for some reason anyone know how to change this? Code attached for context.
clear; clc;
format shortG
syms C1 C2 C3 C4
eqn1= 0.3598*C1 - 0.6445*C2 - 0.6388*C3 + 0.2170*C4 == 0;
eqn2= -0.6155*C1 + 0.3427*C2 - 0.5333*C3 + 0.4683*C4 == 40;
eqn3= 0.5942*C1 + 0.3962*C2 + 0.1659*C3 + 0.6800*C4 == 0;
eqn4= -0.3724*C1 - 0.5570*C2 + 0.5291*C3 +0.5208*C4 == 0;
[A,B] = equationsToMatrix([eqn1, eqn2, eqn3, eqn4], [C1, C2, C3, C4]);
X=linsolve(A,B)
X =
-123100469289600000/5000172844664399
68542380776800000/5000172844664399
-106674157217600000/5000172844664399
93657426868400000/5000172844664399

Respuesta aceptada

Star Strider
Star Strider el 10 de Dic. de 2019
You are still in the Symbolic Math Toolbox environment.
Try one of these (depending on the rresult you want):
X = vpa(linsolve(A,B))
X = double(linsolve(A,B))
The vpa call keeps the results symbolic, the double call makes the results numeric.
  2 comentarios
Michael Finch
Michael Finch el 12 de Dic. de 2019
Thank you this worked perfectly :)
Star Strider
Star Strider el 12 de Dic. de 2019
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by