Matlab Outputting answers as fractions
191 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Michael Finch
le 10 Déc 2019
Commenté : Star Strider
le 12 Déc 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
0 commentaires
Réponse acceptée
Star Strider
le 10 Déc 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Number Theory dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!