Effacer les filtres
Effacer les filtres

how to fix Summation index error?

1 vue (au cours des 30 derniers jours)
reza hamzeh
reza hamzeh le 22 Déc 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)

Réponse acceptée

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 22 Déc 2019
Use this command:
symsum(symsum((vectors(:,m)*(vectors(:,n)'))))
instead of: symsum(symsum((vectors(:,m)*(vectors(:,n)')),m,1,4),n,1,4)

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by