In symbolic expression, how can I factorize terms that has common variables?

I have this expression
det =
I used collect but it returns the following
collect(det,x)
ans =
So, It has been factorized only with resect to x and x.^2 variables.
Is there a way to obtain the equation with the factorization with respect to all the variables?
Thank you ivery much in advance for your help!
Laura

6 commentaires

You can pass a vector of variable names to collect()
Dear Walter,
thank you very much.
I did so and it works:
z = collect(det, [x,y])
z =
Could you also suggest a way to assign a numeric value for each of the monomial coefficient?
For example I would like that:
= -1.07
= -0.02072
..... and so on.
Thank you very much for your help.
Laura
Sorry,
of course they are not monomial but polynomial coefficients for my quadratic function!
Thank you very much!
syms a b c d e f g h i l x y
z = (2*a*h - 2*c*f)*x^2 + (4*a*g-4*b*f)*x*y + (d*h - c*i - 2 * e * f + 2 * a * l) * x
z = 
subs(z, 2*a*h-2*c*f, sym('-1.07'))
ans = 
But I suspect you were looking for something more like
[C, p] = coeffs(z, x, 'all')
C = 
p = 
subs(z, C(1), sym('-1.07'))
ans = 
Dear Walter,
Thank you very much for your help. The first approach that you suggested was that I was looking for.
This is very helpful, like all your previous suggestions.
Kind Regards,
Laura
How Can I accept or validate your answer?
Thanks,
Laura

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange

Produits

Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by