having different results when I put numbers manually and parameterize

I am dealing with an 8th equation and I used vpasolve to store all the roots of that equation.
S = vpasolve(equation, s);
The matrix S contains values of
- 1.9718709247834585063477203451543 - 2.7588590897673713478450366516503i
- 1.9718709247834585063477203451543 + 2.7588590897673713478450366516503i
- 1.6602104863153775396745015860611 - 0.28007873122724886824752325586177i
- 1.6602104863153775396745015860611 + 0.28007873122724886824752325586177i
1.6602104863153775396745015860611 - 0.28007873122724886824752325586177i
1.6602104863153775396745015860611 + 0.28007873122724886824752325586177i
1.9718709247834585063477203451543 + 2.7588590897673713478450366516503i
1.9718709247834585063477203451543 - 2.7588590897673713478450366516503i
I want to use the top four terms from the matrix above, which will be referenced by S(1, 1), S(2, 1), S(3, 1), S(4, 1).
And I made another equation using the four terms.
transferFunction1 = 1 / (e*(s-(S(1, 1)))*(s-(S(2, 1)))*(s-(S(3, 1)))*(s-(S(4, 1))));
and when I collect transferFunction1 using
collect(transferFunction1, s)
the result is like:
3.125e129/(3.140625e128*s^4 + s^3*(2.2814011363464563914077081505446e129 + 2.59375e96i) + s^2*(8.6144845457243503826611646706711e129 + 1.5020097307246571807203237553397e97i) + s*(1.5503047021173869741531698334942e130 + 2.8629059987527271695020531485894e97i) + (1.0237918954506870666034283717819e130 + 1.8164339501566283459635589516081e97i))
This is an undesired result.
And when I rewrite the transfer function with the manually substituted values instead of parameterized variables(S(1, 1), S(2, 1), S(3, 1), S(4, 1)) like below,
transferFunction2 = 1 / (e*(s-(- 1.9718709247834585063477203451543 - 2.7588590897673713478450366516503i))*(s-(- 1.9718709247834585063477203451543 + 2.7588590897673713478450366516503i))*(s-(- 1.6602104863153775396745015860611 - 0.28007873122724886824752325586177i))*(s-(- 1.6602104863153775396745015860611 + 0.28007873122724886824752325586177i)));
Collecting the new equation
collect(transferFunction2, s)
gives a result like:
13164036458569648337239753460458804039861886925068638906788872192000/(1322985664086249657892595222776109806006119635969398210132281655296*s^4 + 9610383275355832527232770828822326943683998340855816099663336964096*s^3 + 36288444362144045831281522444278455028973192738350821636975383019520*s^2 + 65306456385808769742610307072344572612367098640388197158826643816448*s + 43127148280643104621971678322654245056669000802947019363760884284265)
There is no imaginary term, and this is the correct form I've been expecting. I can't understand why the manual substitution is required to get the desired result. What is the difference between transferFunction1 and transferFunction2?

回答(1 个)

You have to substitute the terms as a+b*i, not as a+bi.
Best wishes
Torsten.

1 个评论

I appreciate your help, but I still have the problem.
I don't think the omitted symbol * is the reason why I'm not getting the result I want. Because the expression without * symbol
(- 1.9718709247834585063477203451543 - 2.7588590897673713478450366516503i)
is what's stored in S(1, 1), which means this is the way MATLAB stores a complex number in a variable, this is not what I typed by hand.
Even more, the expression without * symbol
transferFunction1 = 1 / (e*(s-(- 1.9718709247834585063477203451543 - 2.7588590897673713478450366516503i))*(s-(- 1.9718709247834585063477203451543 + 2.7588590897673713478450366516503i))*(s-(- 1.6602104863153775396745015860611 - 0.28007873122724886824752325586177i))*(s-(- 1.6602104863153775396745015860611 + 0.28007873122724886824752325586177i)));
gives the exact result what I need.
13164036458569648337239753460458804039861886925068638906788872192000/(1322985664086249657892595222776109806006119635969398210132281655296*s^4 + 9610383275355832527232770828822326943683998340855816099663336964096*s^3 + 36288444362144045831281522444278455028973192738350821636975383019520*s^2 + 65306456385808769742610307072344572612367098640388197158826643816448*s + 43127148280643104621971678322654245056669000802947019363760884284265)
The weired thing is that MATLAB shows different results when I reference the values using variable name and when I copy and paste the values inside variables.
Why do I have to copy and paste the values inside variables to get the correct result?
I think there must be a way I can reference the values inside variables without copying and pasting it manually by hand while running a code.

请先登录,再进行评论。

类别

Community Treasure Hunt

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

Start Hunting!

Translated by