How can I remove parentheses in a symbolic expression and perform the operations for the coefficients?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Zoltán Csáti
am 15 Mär. 2014
Kommentiert: Zoltán Csáti
am 15 Mär. 2014
I cannot use parentheses and / operations in my code because PHClab can't interpret them. So I need to remove them. How can I make it? For example I have
x2/24 - x1/6 + (x1*x4)/8 + (2*x3)/15 - (11*x4)/120 - x5/14 + (5*x6)/56 + x7/2 - x8 + x9
and I need
0.04167*x2 - 0.1667*x1 + 0.125*x1*x4 + ... + x9
Thank you
2 Kommentare
Akzeptierte Antwort
Mischa Kim
am 15 Mär. 2014
Bearbeitet: Mischa Kim
am 15 Mär. 2014
syms x2 x1 x4 x3
f = x2/24 - x1/6 + x1*x4/8 + 2*x3/15
f =
x2/24 - x1/6 + (2*x3)/15 + (x1*x4)/8
vpa(f,5) % the "5" denotes the number of significant digits
ans =
0.041667*x2 - 0.16667*x1 + 0.13333*x3 + 0.125*x1*x4
3 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numbers and Precision finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!