Can not calculate coefficient Accurately
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Lokesh
2024-3-27
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 个评论
Star Strider
2024-3-27
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!