Use of (ilaplace) give different result through sym variable and directly

177 views Asked by At

I have a symbolic variable, which contain, for example:

    p =

(9311.0*s + 6.12e9)/(s^2 + 8500.0*s + 3.61e11)

where s - also symbolic. Then, if I use inverse laplace through variable p, then result is

>>result=vpa(ilaplace(p,s,n),3)
 result =
 exp(n*(- 4255.0 + 6.01e5*i))*(4666.0 - 5066.0*i) + exp(n*(- 4255.0 - 6.01e5*i))*(4666.0 + 5066.0*i)

But if I put expression directly, I will get what I expect (by formula in Korn's book or by definition):

vpa(ilaplace((9311.0*s + 6.12e9)/(s^2 + 8500.0*s + 3.61e11),s,n),3)

ans =

9311.0*exp(-4255.0*n)*(cos(6.01e5*n) + 1.09*sin(6.01e5*n))

Why? And what should I do to get right answer through variable?

P.S. vpa - is not influenced on main goal. It only left 3 digits in this case after point.

P.S.S. Added more code:

t = tf(linsys1) %linsys1 - from simulink circuit
%get coefficients from transfer function t
   [num,den] = tfdata(t);

   syms s n real 
   % convert transfer function to symbolic
   t_sym = poly2sym(cell2mat(num),s)/poly2sym(cell2mat(den),s);

   functionInMuPad=['partfrac(',char(t_sym),',s,Domain = R_)']; %collect expression in string format 
   simpleFraction=evalin(symengine,functionInMuPad); % sum of simple fractions (only MuPad allows get denominator of 2nd order)

  functionInMuPad2=['op(',char(simpleFraction),')']; %collect expression in string format 
   vectorOfOperand=evalin(symengine,functionInMuPad2); % vector of simple fractions

for k=1:length(vectorOfOperand)-1
z(k,1)=ilaplace(vectorOfOperand(k),s,n); 
end

So, something wrong with vectorOfOperand. ilaplace(vectorOfOperand(1)) gives complex result, but if copy (ctrl+c) value of vectorOfOperand(1) and make newVariable=Ctrl+V, then ilaplace(newVariable) - it's ok either in command window or in m-file:

bbb =(9313.8202564498255348020392071286*s + 6122529964.4040716985063406588769)/(8500.4056471180697831891961467533*s + s^2 + 360665607284.96754103451618653904);
ilaplace(bbb,s,n)
ans=9311.0*exp(-4255.0*n)*(cos(6.01e5*n) + 1.09*sin(6.01e5*n)) %after vpa

Kind of magic anyway. vectorOfOperand - is sym. I even made this: vectorOfOperand=char(vectorOfOperand); vectorOfOperand=sym(vectorOfOperand); it doesn't help..

0

There are 0 answers