필터 지우기
필터 지우기

how to plot a defined function ?

조회 수: 3 (최근 30일)
reza hamzeh
reza hamzeh 2019년 10월 22일
댓글: Christine Tobler 2019년 10월 28일
hi. i coded 2 functions. now i want to plot N(t) versus T. but it gives me errors. plz help me to do that.
clear;
T=0:0.1:14;
plot(T,N(t))
function pa = partialtranspos(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
  댓글 수: 1
Adam
Adam 2019년 10월 22일
If it gives you errors then post the error messages here to make it easier for people to help.

댓글을 달려면 로그인하십시오.

답변 (1개)

reza hamzeh
reza hamzeh 2019년 10월 22일
these are the errors. plz help me.
Error using /
Matrix dimensions must agree.
Error in fortest>partialtranspose (line 13)
ro = expm(-H/T)/trace(expm(-H/T));
Error in fortest>N (line 20)
ne=0.5*(sum(abs(eig(partialtranspose(T))))-1);
Error in fortest (line 4)
plot(T,N(T))
  댓글 수: 1
Christine Tobler
Christine Tobler 2019년 10월 28일
H is a square matrix, while T is a row vector. The operation H / T is not supported, because this is trying to compute X which solves the linear system X*T = H, which is not possible when H is of size 4-by-4 and T is of size 1-by-141.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by