Azzera filtri
Azzera filtri

I want to take an Equation as input like ax^2+bx+c =0 , Now I want to take the co-efficient. What will be the code?

10 visualizzazioni (ultimi 30 giorni)
I want to take an Equation as input like ax^2+bx+c =0 , Now I want to take the co-efficient. What will be the code?

Risposte (1)

Karan Gill
Karan Gill il 20 Giu 2016
Modificato: Karan Gill il 17 Ott 2017
You could try the coeffs command. Note that coeffs accepts polynomial input, not equation input.
>> syms a b c x
poly = a*x^2 + b*x + c;
C = coeffs(poly, x)
C =
[ c, b, a]
You might prefer flipping the order of C to match the order of f.
>> fliplr(C)
ans =
[ a, b, c]
  1 Commento
Sourin Dey
Sourin Dey il 24 Giu 2016
Modificato: Sourin Dey il 24 Giu 2016
Thanks for your comment, but I want to take the equation as input,It can be any equation . I mean user input . then will take the coefficients from the equation. My purpose is to develop a code for Newton-Raphson Method.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by