Creating matrices with elements as a function of kroneckerDelta
2 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I want to create some spin matrices for which I know the elements as a function of matrix index and kroneckerDelta function. The functions are given here Spin Matrices.
Here's the snippet of the code:
S = 1;
syms m n
for m = -S:1:S
for n = -S:1:S
sx{m,n} = (kroneckerDelta(m,n+1) + kroneckerDelta(m+1,n))*sqrt(S*(S+1) - m*n)/2;
sy{m,n} = (kroneckerDelta(m,n+1) - kroneckerDelta(m+1,n))*sqrt(S*(S+1) - m*n)/(2*1i);
sz{m,n} = kroneckerDelta(m,n)*m;
s_plus{m,n} = kroneckerDelta(m,n+1)*sqrt(S*(S+1) - m*n);
s_minus{m,n} = kroneckerDelta(m+1,n)*sqrt(S*(S+1) - m*n);
end
end
The snippet gives errors in kroneckerDelta Function and the indices of the matrices. Can anyone help me in debugging this?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematical Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!