how to fix Summation index error?
2 ビュー (過去 30 日間)
古いコメントを表示
reza hamzeh
2019 年 12 月 22 日
回答済み: Sulaymon Eshkabilov
2019 年 12 月 22 日
hi every body.
my codes give me errors. plz help me to fix it.
clear;
syms x;
sy=[0 -1i;1i 0];
s=kron(sy,sy);
t=1;
de=50;
range1=0:0.1:10;
innerstate=[1 1 0 0;1 1 1 1;1 1 1 0;1 0 1 0];
ro=zeros(size(innerstate,1));
rov=zeros(size(innerstate,1));
Ha='[x/2 0 0 0;0 -x/2 x 0;0 x -x/2 0;0 0 0 x/2]';
Haf = str2func(sprintf('@(%s)%s;','x',Ha));
[vectors,values]=eig(Haf(x));
for n=1:size(innerstate,1)
for m=1:size(innerstate,1)
ro=ro+(vectors(:,m)*(vectors(:,n)'));
end
end
symsum(symsum((vectors(:,m)*(vectors(:,n)')),m,1,4),n,1,4)
Error using sym/symsum (line 52)
Unable to compute sum with respect to '4'. Summation index must be
a symbolic variable.
Error in remove_shadow (line 22)
symsum(symsum((vectors(:,m)*(vectors(:,n)')),m,1,4),n,1,4)
0 件のコメント
採用された回答
Sulaymon Eshkabilov
2019 年 12 月 22 日
Use this command:
symsum(symsum((vectors(:,m)*(vectors(:,n)'))))
instead of: symsum(symsum((vectors(:,m)*(vectors(:,n)')),m,1,4),n,1,4)
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!