discrepancy of symbolic calculations for MATLAB 2010a and MATLAB 2012a

1 visualización (últimos 30 días)
Qingbin
Qingbin el 14 de Abr. de 2014
Editada: Qingbin el 15 de Abr. de 2014
I obtained two different results while running the following code using MATLAB 2010a and MATLAB 2012a respectively. Using MATLAB 2010a, I obtained 0 for delta1_sub as the result. Using MATLAB 2012a, I obtained that delta1_sub equals the following:
(60*w*sin((5*w)/2) - 20*cos((5*w)/2) - sin((5*w)/2)*20*i - w*cos((5*w)/2)*60*i - w*84*i - 32*w^2 + w^3*12*i - 32)
Any idea of what is happening would be greatly appreciated.
clc;clear all;
syms s alpha1 alpha2;
syms z1 z2 w real;
cos1=(1-z1^2)/(1+z1^2);
cos2=(1-z2^2)/(1+z2^2);
sin1=2*z1/(1+z1^2);
sin2=2*z2/(1+z2^2);
e1=cos1-sin1*1i;
e2=cos2-sin2*1i;
A=[0 1;
-8 -3];
B1=[0 0;
-1 -3];
B2=[0 0;
-8 1];
B3=[0 0;
-5 0];
n=size(A,1);
tau3=2.5;
ce=numden(simplify(det(s*eye(n)-A-B1*e1-B2*e2-B3*(cos(tau3*w)-1i*sin(tau3*w)))));
cez=collect(subs(ce,s,w*1i),w);
CEre=collect(real(cez),z2);
CEim=collect(imag(cez),z2);
CEre_alpha2=subs(CEre,z2,alpha2);
CEim_alpha2=subs(CEim,z2,alpha2);
delta1=collect(factor(CEre*CEim_alpha2-CEim*CEre_alpha2)/(z2-alpha2),alpha2)
delta1_sub=vpa(subs(delta1,z1,1i))
  2 comentarios
Walter Roberson
Walter Roberson el 14 de Abr. de 2014
Note: do not eval() a symbolic expression. Use vpa() or double()
Qingbin
Qingbin el 15 de Abr. de 2014
Editada: Qingbin el 15 de Abr. de 2014
Thanks, Walter. When I run this code using MATLAB 2010a, delta1 has a factor (z1^2 + 1) which is not the case if I run the code using MATLAB 2012a. That is the reason for which I evaluate delta1 at z1=1i. The results are different and I have no idea which one is correct. I did the same in MAPLE 13, again delta1 has no factor (z1^2 + 1) but when I evaluate it at z1=1i, delta1 becomes 0.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by