how to fix Summation index error?

2 Ansichten (letzte 30 Tage)
reza hamzeh
reza hamzeh am 22 Dez. 2019
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)

Akzeptierte Antwort

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 22 Dez. 2019
Use this command:
symsum(symsum((vectors(:,m)*(vectors(:,n)'))))
instead of: symsum(symsum((vectors(:,m)*(vectors(:,n)')),m,1,4),n,1,4)

Weitere Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by