我試圖得到一個函數來計算schmidt分解的兩部分狀態(兩個密度矩陣的張量)來打印施密特數(X)和基向量(e_i ,e_j)for循環的每次迭代。例如:(x'*'e_1'\ otimes'e_1 + ... + x'*'e_i'\ otimes'e_j)。註釋掉的fprintf語句是我已經嘗試過的。Matlab,並排打印輸出向量
代碼:
function [u, v] = Schmidt(m,n,v)
m = 3 %size of basis vector
n = 4 %size of basis vector
e_m = eye(m)
e_n = eye(n)
%can have a = input('enter an array>');
v = [1
2
3
4
5
6
7
8
9
10
11
12]
for i = 1:m
for j = 1:n
e_i = e_m(:,i)
e_j = e_n(:,j)
K = kron(e_i, e_j)
x = ctranspose(K)*v
W(i,j) = x
%fprintf('%d %f %f %f\n',j,e_i,e_j,x);
%fprintf(1,'Header 1\tHeader 2\n');
%fprintf(1,'%f\t%f\n','e_i e_j');
%fprintf('the basis are %d\n',e_i, e_j)
end
end
end
所以你要多少數量並排在每次迭代,什麼是他們的變量名? – jerad
如果你想把所有的數字放在同一行,你可以使用disp([a b c d]) – jerad