フィルターのクリア

how to fix Summation index error?

1 回表示 (過去 30 日間)
reza hamzeh
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)

採用された回答

Sulaymon Eshkabilov
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 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by