Converting syms to double
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I'm trying to solve for multiple phase shifts using syms. However, when I try to convert to a double in my last switch, I get the error: "Conversion to 'sym' from 'struct' is not possible". I assumed it was because it was trying to use angles between -inf to inf, but after forcing it to assume that phi and theta were between -pi and pi, it still wouldn't allow me to see the values of my angles. I think I might be overcomplicating this. Can someone help me please?
i=sqrt(-1);
%Basic spin 1 kets
zket(:,1)=[1;0;0];
zket(:,2)=[0;1;0];
zket(:,3)=[0;0;1];
xket(:,1)=[.5;1/sqrt(2);.5];
xket(:,2)=[1/sqrt(2);0;-1/sqrt(2)];
xket(:,3)=[.5;-1/sqrt(2);.5];
yket(:,1)=[.5;i/sqrt(2);-.5];
yket(:,2)=[1/sqrt(2);0;1/sqrt(2)];
yket(:,3)=[.5;-i/sqrt(2);-.5];
%Basic spin 1 bras
zbra=conj(zket');
xbra=conj(xket');
ybra=conj(yket');
Unknown1=[.25,1,.25;.5,0,.5;.25,0,.25];
Unknown2=[.55,.865,.25;.45,.130,.5;.05,.005,.25];
Unknown3=[.15,.03,(1/3);.7,0,(1/3);.15,.97,(1/3)];
Unknown4=[.25,.25,.5;.5,.5,0;.25,.25,.5];
for Part=1:4
switch Part
case 1
Psi=Unknown1;
case 2
Psi=Unknown2;
case 3
Psi=Unknown3;
case 4
Psi=Unknown4;
end
a(Part)=sqrt(Psi(1,3));
b(Part)=sqrt(Psi(2,3));
c(Part)=sqrt(Psi(3,3));
syms theta phi
assume(theta>=-pi);
assumeAlso(theta<=pi);
assume(phi>=-pi);
assumeAlso(phi<=pi);
Newb=b(Part)*exp(i*theta);
Newc=c(Part)*exp(i*phi);
NewPsi=a(Part)*zket(:,1)+Newb*zket(:,2)+Newc*zket(:,3);
XZERO=(xbra(2,:)*NewPsi)*conj(xbra(2,:)*NewPsi);
XNEG=(xbra(3,:)*NewPsi)*conj(xbra(3,:)*NewPsi);
YZERO=(ybra(2,:)*NewPsi)*conj(ybra(2,:)*NewPsi);
YNEG=(ybra(3,:)*NewPsi)*conj(ybra(3,:)*NewPsi);
SolnsZero=solve(Psi(2,1)==XZERO,Psi(2,2)==YZERO,theta,phi)
SolnsNeg=solve(Psi(3,1)==XNEG,Psi(3,2)==YNEG,theta,phi)
switch Part
case 1
Zero1=subs(SolnsZero)
Neg1=subs(SolnsNeg)
case 2
Zero2=subs(SolnsZero)
Neg2=subs(SolnsNeg)
case 3
Zero3=subs(SolnsZero)
Neg3=subs(SolnsNeg)
case 4
Zero4=subs(SolnsZero)
Neg4=subs(SolnsNeg)
end
end
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Conversion Between Symbolic and Numeric finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!