plot a defined function

17 ビュー (過去 30 日間)
reza hamzeh
reza hamzeh 2019 年 10 月 22 日
回答済み: Star Strider 2019 年 10 月 22 日
hi people. i wrote two functions. they work correctly. now i want to plot the function N(T) versus T in range 0.1 to 14 . but i dont know how to do that.
maybe someone help me plz ?
clear;
function pa = partialtranspose(T)
J=1;B=4;d=4;
s0=[1 0;0 1];
sx=[0 1;1 0];
sy=[0 -1i;1i 0];
sz=[1 0;0 -1];
H = 2*J*kron(sz,sz)+B*(kron(sz,s0)+kron(s0,sz))+d*(kron(sx,sy)-kron(sy,sx));
ro = expm(-H/T)/trace(expm(-H/T));
pa = [ro(1,1) ro(2,1) ro(1,3) ro(2,3);ro(1,2) ro(2,2) ro(1,4) ro(2,4);
ro(3,1) ro(4,1) ro(3,3) ro(4,3);ro(3,2) ro(4,2) ro(3,4) ro(4,4)];
end
function ne = N(T)
ne=0.5*(sum(abs(eig(partialtranspose(T))))-1);
end

採用された回答

Star Strider
Star Strider 2019 年 10 月 22 日
You can define ‘N’ as an anonymous function.
Try this:
N = @(T) 0.5*(sum(abs(eig(partialtranspose(T))))-1);
Tv = linspace(0.1, 14, 10); % Define Rnage Of ‘T’
for k = 1:numel(Tv)
Nv(k) = N(Tv(k));
end
figure
plot(Tv, Nv)
grid
I used the loop because ‘partialtranspose’ is not vectorised.
See the documentation on Anonymous Functions for more information on them.

その他の回答 (1 件)

M
M 2019 年 10 月 22 日
plot the function N(T) versus T in range 0.1 to 14
T is known ? T =[0.1 : 14 ] ?
And you want to plot ne(T) ?
In this case you could simply write
plot(T,ne)

カテゴリ

Help Center および File ExchangeQuantum Mechanics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by