Check summation from n=0 to 5 |n><n| in MATLAB?
5 views (last 30 days)
Show older comments
Abu Zar
on 11 Jan 2023
Answered: Bjorn Gustavsson
on 11 Jan 2023
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|
0 Comments
Accepted Answer
Bjorn Gustavsson
on 11 Jan 2023
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 Comments
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!