how to fix Summation index error?

3 visualizzazioni (ultimi 30 giorni)
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)

Risposta accettata

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

Più risposte (0)

Categorie

Scopri di più su Mathematics in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by