Decreasing digits of answer
Afficher commentaires plus anciens
Hello,
grad =

I have an output like this, but I want at most 6 digit of numbers. How can I change it? Please help me.
Thank you so much
Réponses (1)
Paul
le 6 Juin 2023
Try:
vpa(grad,6)
9 commentaires
John Adams
le 6 Juin 2023
Paul
le 6 Juin 2023
Can you post the the code that generates grad, or save it to a .mat file and post add it to your question using the paper clip icon. Hard to help without being able to recreate the results.
John Adams
le 6 Juin 2023
Modifié(e) : Walter Roberson
le 6 Juin 2023
syms x y
x1=2.234;
y1=2.24;
x2=5.34;
y2=5.5452;
x3=2.123;
y3=5.153;
x4=3.656;
y4=5.03;
x5=2.6001;
y5=6.253;
x6=1.933;
y6=3.411;
A= [1 x y x^2 x*y y^2]
B= [1 x1 y1 x1^2 x1*y1 y1^2;1 x2 y2 x2^2 x2*y2 y2^2;1 x3 y3 x3^2 x3*y3 y3^2;
1 x4 y4 x4^2 x4*y4 y4^2;1 x5 y5 x5^2 x5*y5 y5^2;1 x6 y6 x6^2 x6*y6 y6^2;]
invB= inv(B)
C= A * invB
vpa(C,6)
But what I suspect you are looking for is
digits(6)
FPO = sympref('floatingpointoutput', true);
syms x y
x1=2.234;
y1=2.24;
x2=5.34;
y2=5.5452;
x3=2.123;
y3=5.153;
x4=3.656;
y4=5.03;
x5=2.6001;
y5=6.253;
x6=1.933;
y6=3.411;
A= [1 x y x^2 x*y y^2]
B= [1 x1 y1 x1^2 x1*y1 y1^2;1 x2 y2 x2^2 x2*y2 y2^2;1 x3 y3 x3^2 x3*y3 y3^2;
1 x4 y4 x4^2 x4*y4 y4^2;1 x5 y5 x5^2 x5*y5 y5^2;1 x6 y6 x6^2 x6*y6 y6^2;]
invB= inv(B)
C= A * invB
sympref('floatingpointoutput', FPO) %restore setting
John Adams
le 6 Juin 2023
John Adams
le 6 Juin 2023
Modifié(e) : John Adams
le 6 Juin 2023
Walter Roberson
le 6 Juin 2023
The sympref always uses 4. I misled when I showed digits(6) as if it controlled the output digits for the sympref
Paul
le 6 Juin 2023
To be clear, 'floatingpointoutput' = true only affects the display of results, not the results themselves.
Catégories
En savoir plus sur Equation Solving dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




