Check summation from n=0 to 5 |n><n| in MATLAB?

1 次查看(过去 30 天)
D=5;
tmpI=eye(D);
ket0=tmpI(:,1); %|0>
ket1=tmpI(:,2); %|1>
ket2=tmpI(:,3); %|2>
ket3=tmpI(:,4); %|3>
ket4=tmpI(:,5); %|4>
ket5=tmpI(:,6); %|5>
% bra is the transpose of ket
bra0=tmpI(1,:); % <0|
bra1=tmpI(2,:); % <1|
bra2=tmpI(3,:); % <2|
bra3=tmpI(4,:); % <3|
bra4=tmpI(5,:); % <4|

采纳的回答

Bjorn Gustavsson
Bjorn Gustavsson 2023-1-11
If |n><n| is the same as <n||n> then you should have a look at the help and documentation to dot. That function will not generalize well to the more general <n|G|n>. For that you might get away with the standard vector-matrix-vector products where you'll have to make some discrete version of the operator G. If |n><n| is not the same as <n||n> you might have to explain what it is supposed to be.
HTH

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by