How to define partial fraction expansion?

54 visualizaciones (últimos 30 días)
mir
mir el 5 de Sept. de 2023
Comentada: mir el 9 de Sept. de 2023
Hi everyone,
I would like to expand the development of the partial fractions of a function F starting from [r,p,k] = residue(F).
Is there a function that allows you to do this?
  2 comentarios
Dyuman Joshi
Dyuman Joshi el 5 de Sept. de 2023
"I would like to explain the development of the partial fractions of a function F starting from [r,p,k] = residue(F)."
What exactly do you mean by "explain the developement"?
mir
mir el 5 de Sept. de 2023
Editada: mir el 5 de Sept. de 2023
s =tf('s')
s = s Continuous-time transfer function.
F = (s-1)/(s+2)
F = s - 1 ----- s + 2 Continuous-time transfer function.
N_f = F.Numerator{1}
N_f = 1×2
1 -1
D_f = F.Denominator{1}
D_f = 1×2
1 2
[r,p,k] = residue(N_f,D_f)
r = -3
p = -2
k = 1
I would see the function:
F_residue = 1 - 3/(s+2)
so as a sum of terms

Iniciar sesión para comentar.

Respuestas (4)

Dyuman Joshi
Dyuman Joshi el 5 de Sept. de 2023
"I would see the function:
F_residue = 1 - 3/(s+2)
so as a sum of terms"
One method would be to use symbolic variables (Note - requires symbolic toolbox) -
s =tf('s');
F1 = (s-1)/(s+2);
F_res1 = expr(F1)
F_res1 = 
F2 = (-4*s+8)/(s^2+6*s+8);
F_res2 = expr(F2)
F_res2 = 
function F_res = expr(F)
N_f = F.Numerator{1};
D_f = F.Denominator{1};
[r,p,k] = residue(N_f,D_f);
syms s
if isempty(k)
k=0;
end
F_res = k + sum(r./(s-p));
end
  4 comentarios
Dyuman Joshi
Dyuman Joshi el 9 de Sept. de 2023
Sorry for the late reply, I did not get the notification for your reply somehow.
You are right, I did not incorporate poles with multiplicity more than 1.
It would be better to use partfrac, rather than trying to modify the code I wrote.
%Directly use partfrac
syms s
F = (s-4)/(s*(s+2)^2);
out = partfrac(F)
out = 
%or via transfer function
s = tf('s');
F = (s-4)/(s*(s+2)^2);
N_f = F.Numerator{1};
D_f = F.Denominator{1};
n = numel(N_f);
syms s
F0 = (s.^(n-1:-1:0)*N_f')/(s.^(n-1:-1:0)*D_f')
F0 = 
out0 = partfrac(F0)
out0 = 
mir
mir el 9 de Sept. de 2023
@Dyuman Joshi don't worry, I solved it
Thank you so much!

Iniciar sesión para comentar.


Ayush Anand
Ayush Anand el 5 de Sept. de 2023
Hi Mir,
I understand you are looking for a function that can compute the partial fraction decomposition of a function. MATLAB provides a function called "residue" that can be used for this purpose. The "residue" function takes the coefficients of the numerator and denominator polynomials of the rational function as inputs and returns the residues, poles, and constant term of the partial fraction expansion.
You can read more about the syntax and use cases of "residue" here:
I hope this helps!

Shubham
Shubham el 5 de Sept. de 2023
Hi,
MATLAB provides a function called residue that can be used to perform partial fraction decomposition of a rational function. The residue function calculates the residues and poles of a given function.
To read more about residue, refer to this documentation.
Hope this helps. Thanks

John D'Errico
John D'Errico el 5 de Sept. de 2023
Editada: John D'Errico el 5 de Sept. de 2023
You already know about the existence of the function residue.m.
Therefore your question is truly to "explain the development" of that partial fraction expansion. For that, you can read the docs surrounding residue, thus by reading here: residue.
You might look at the code itself in the function residue. If you do that, then PLEASE, PLEASE, DO NOT EDIT THE FUNCTION. We see so many times where some one has edited a MATLAB supplied function, and not reaizing they did so, make some silly edit to the code by accident, and then save the function. If you want to look at the code, then do this:
type residue
However, my guess is you won't get far there, as the code has a lot in it, and is probably not illuminating. A new user to MATLAB will just find themselves confused.
Or, you might want to do some reading, to understand how a partial fraction expansion is performed. Maybe start here in the reference provided in residue itself:
Reference: A.V. Oppenheim and R.W. Schafer, Digital
Signal Processing, Prentice-Hall, 1975, p. 56-58.
Or you might look here:
But I'm afraid, if by "explain" you want something that will take you step by step through the specific mathematical computations that were performed, there is no tool in MATLAB that will do that, thus teaching you how to perform a specific partial fraction expansion on some specific problem. (I think Mathematica/Alpha will do things like that, for at least some problems, but I don't use that tool.)

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by