MATLAB Answers

ilaplace confusing - result from command window and from m file gui is not the same

1 view (last 30 days)
john
john on 20 Jan 2014
Edited: john on 27 Feb 2014
Hi,
I write in command window:
ilaplace((0.99984898859777815438576453743735*s^2 + 1414.0*s - 414151.01140222184561423546256265)/((s + 1000.0)*(s^2 + 1000000.0)))
And I got : ans =
(199002808534433793169*cos(1000*t))/140737488355328000000 - 58286573144567511919/(140737488355328000000*exp(1000*t)) - (1169*sin(1000*t))/140737488355328000000
I write the same in m file from GUI and I got:
0.707*exp(1000.0*t*i) - 0.41415101140222184561423546256265/exp(1000.0*t) + 0.707*(1/exp(1000.0*t*i))
WHY I GOT COMPLEX NUMBER? "i"?

Accepted Answer

Mischa Kim
Mischa Kim on 21 Jan 2014
Edited: Mischa Kim on 21 Jan 2014
Hello John, it is actually the same. Try plotting the two results.
The reason you get complex numbers is because of Euler's formula:
exp^(ix) = cos(x) + i*sin(x)
If you analyze the results you'll see that you get (really) small imaginary numbers. That's because the computation is done in floating point arithmetic (see this answer). In case you are not comfortable with the imaginary parts, just plot the real parts.
  12 Comments

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!