Can not calculate coefficient Accurately
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
My equation is
Disp =X1*(4*X2 - 4*X1 + 1)
I am using Fallowing Command
[EQ_01, T] =coeffs(Disp , [X1 X2])
N1 = EQ_01(1) by using this cammand i got fallowing answer
N1 = -4
My required answer is 1 - 4X1
N2 = EQ_01(2) by using this cammand i got fallowing answer
N2 =4
My required answer is
4X1
0 commentaires
Réponses (2)
Lokesh
le 27 Mar 2024
Hi inzamam,
As per my understanding, the values of coefficients returned from 'coeffs' is different from your expected values.
Given your equation 'Disp =X1*(4*X2 - 4*X1 + 1)' and the MATLAB command '[EQ_01, T] =coeffs(Disp , [X1 X2])' , 'coeffs' returns the coefficients of 'Disp' with respect to the symbolic variables 'X1' and 'X2'. When extracting coefficients of 'Disp' with 'X1' and 'X2' as variables, the equation simplifies to '-4X1^2 + 4X1X2 + X1'. This operation will return the coefficients of 'X1^2', 'X1X2' , and 'X1', which are -4, 4, and 1, respectively.
It is important to note that when obtaining coefficients with respect to 'X1', 'X1' itself cannot appear in the coefficients. This is because the operation is designed to isolate the factors multiplying 'X1' directly, not to include 'X1' as part of its own coefficient.
Refer to the following documentation to know more about 'coeffs':
0 commentaires
Star Strider
le 27 Mar 2024
Only request the coefficients of ‘X2’ and then divide ‘EQ_01(2)’ by ‘X1’ —
syms X1 X2
Disp = X1*(4*X2 - 4*X1 + 1)
[EQ_01, T] =coeffs(Disp , X2)
EQ_01(2) = EQ_01(2)/X1
If you are required to get that result without the extra division by ‘X1’, be sure that you entered ‘Disp’ correctly.
.
0 commentaires
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox 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!