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

8 次查看(过去 30 天)
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,

回答(1 个)

Star Strider
Star Strider 2021-10-22
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.
.

类别

Help CenterFile Exchange 中查找有关 Formula Manipulation and Simplification 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by