How to show exact answers when using the "residue(a,b)" command
9 views (last 30 days)
Show older comments
billyandriam
on 14 Nov 2020
Commented: Star Strider
on 14 Nov 2020
I have this math problem in which I am trying to expand a rational function of the form
into something that looks like this:

where the numerators
and p are constants. To take an example, I have the following function
and when I tried to expand this manually, I found this result: 

Now, that was a relatively easy example and I may need MATLAB in order to quicken my calculations when I deal with higher order denominators and the function residue() allows that. In the console, I tried this:
>>N = [2];
>>D = [1 12 36 0];
>>[r p y] = residue(N,D)
r =
-0-0556
-0.3333
0.0556
p=
-6
-6
0
y=
[]
Now, the solution found by residue() certainly agrees with the one I found manually, but I need exact not numerical solutions with decimal points. I was searching on the forum before asking my question, then found this thread. Basically, it suggests to use symbolic arithmetic with the sym command.
Therefore, I tried to proceed as such but the residue() command only accepts inputs which are floats. Here is the error message I received:

0 Comments
Accepted Answer
Star Strider
on 14 Nov 2020
This is a partial fraction expansion (decomposition), so use the partfrac function (introduced in R2015a):
syms s V(s)
V = 2/(s^3 + 12*s^2 + 36*s)
Vpf = partfrac(V)
pretty(Vpf)
producing:
.
2 Comments
More Answers (0)
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!