Can not calculate coefficient Accurately

2 visualizzazioni (ultimi 30 giorni)
inzamam shoukat
inzamam shoukat il 27 Mar 2024
Risposto: Star Strider il 27 Mar 2024
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

Risposte (2)

Lokesh
Lokesh il 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':

Star Strider
Star Strider il 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)
Disp = 
[EQ_01, T] =coeffs(Disp , X2)
EQ_01 = 
T = 
EQ_01(2) = EQ_01(2)/X1
EQ_01 = 
If you are required to get that result without the extra division by ‘X1’, be sure that you entered ‘Disp’ correctly.
.

Categorie

Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by