Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Partial Fraction Expansion Program Error
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Ethan Robinson

Posts: 5
Registered: 12/10/10
Partial Fraction Expansion Program Error
Posted: Feb 16, 2013 3:53 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello, I wrote a program today for a HW assignment in one of my courses and I'm getting an unusual answer from it. The program uses residue to give me the residues, poles and extra terms for the expanded function, or if I give it the r,p,k it will give me the original function. My code is below, keep in mind I've got little experience programming:

strResponse = input('0 = r,p,k from B(s)/A(s), 1 = opposite : ');
disp(' ')
if strResponse == 0

n = input('Does A, B or A and B need expanded? [a,b,ab,N with apostrophes]: ');
syms s y;

if n == 'N'
B = input(' B = ');
A = input(' A = ');
elseif n == 'a'
As = expand(input('Type A in terms of s: '));
A = sym2poly(As)
B = input(' B = ');
elseif n == 'b'
By = expand(input('Type B in terms of y (swap for s): '));
B = sym2poly(By)
A = input(' A = ');
elseif n == 'ab'
As = expand(input('Type A in terms of s: '));
A = sym2poly(As)
Bs = expand(input('Type B in terms of s: '));
B = sym2poly(Bs)
end

[r,p,k] = residue(B,A)

else
r = input(' r = ');
p = input(' p = ');
k = input(' k = ');

[B,A] = residue(r,p,k)
end

The problem arises when I try to expand: 6 / ((s^2 + 1)*(s^2 +36))
It gives me non-real answers for the residues and poles, whereas if I do the expansion by hand I get real answers for residues and poles (and the correct answer).

Does anyone know why it isn't working correctly?



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.