Complex Number resulted in DOUBLE cannot convert the input expression into a double array

I have done some digging and searching, but I cannot find solution for the particular error. I suspect it is the i acting as symbolic, but I am not sure. Below shows the code and the output. Please help me resolve this issue! Thank you!
Code:
A = [0 1
-2 -3];
B=[0
1];
tr = 0.5;
po = 0.05;
%zeta, omega, and z, w are to calculate damping and natural frequency
syms zeta omega;
[z, w] = solve([tr == (2.16 * zeta+0.6)/omega, po == exp(-1 * zeta * pi / sqrt(1-zeta^2))], [zeta, omega]);
z = vpa(z,4)
w = vpa(w,4)
Poles = [-z*w+w*sqrt(z^2-1) -z*w-w*sqrt(z^2-1)]
place(A,B,Poles)
Output (error occurs at place):
Error using symengine
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use VPA.

댓글 수: 2

Please show the complete error message.
One thing to remember is that vpa() does not convert the value to double precision, so your z and w stay symbolic after the vpa()
Thank you for replying. The output, including Poles output is attached below.
Poles =
[ - 2.886 + 3.026i, - 2.886 - 3.026i]
Error using symengine
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use VPA.
Error in sym/double (line 588)
Xstr = mupadmex('symobj::double', S.s, 0);
Error in sym/subsindex (line 735)
X = double(A) - 1;
Error in sym/subsref (line 776)
R_tilde = builtin('subsref',L_tilde,Idx);
Error in place (line 71)
P = [P(~imag(P)) ; Pc ; conj(Pc)];

댓글을 달려면 로그인하십시오.

 채택된 답변

Use
z = double( vpa(z,4) );
w = double( vpa(w,4) );

댓글 수: 2

I apply the double() on the Poles variable and it works perfectly. Is it because vpa takes i as symbols, and applying double would convert it to imaginary number?
Thanks in advance
I am not sure. I think it might be because you build a vector of the vpa results and it might be having trouble converting symbolic vectors

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

질문:

2016년 4월 14일

댓글:

2016년 4월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by