How to extract symbolic parts and corresponding constant values with division in symbolic polynomials?

8 views (last 30 days)
if the polynomial function f is given like this, I can use coeffs function
syms x
f = cos(x)+x;
[a,b]=coeffs(f)
a = 
b = 
However, if the function f is give as follows
syms x dxdt
f=cos(x)/x+ (x+5)/(x+3);
[a,b]=coeffs(f)
it returns error.
The result I want to have it
a = [1 1 5]
b = [ cos(x)/x x/(x+3) 5/(x+3) ]
Would it be any way to return this result??
Best,

Answers (1)

Star Strider
Star Strider on 22 Oct 2021
I cannot find any function that would return the desired result, however ther are other options, a few of which are —
syms x dxdt
f=cos(x)/x+ (x+5)/(x+3)
f = 
pff = partfrac(f,x)
pff1 = 
ff = factor(f)
pff2 = 
cf = children(f)
cf = 1×2 cell array
{[cos(x)/x]} {[(x + 5)/(x + 3)]}
See Choose Function to Rearrange Expression for a list of all of them, with examples.
.

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!