Why is this code not working whilst the other is?
이전 댓글 표시
I have written this script:
function sum = Sum2(x,y,z)
s = 0;
for i=0:min(x,y)
for k=0:y-i
s = s + (-1)^k * QuantumDimension(2*x+k-2*i, 2*y-2*k-2*i) * Twist(2*x+k-2*i, 2*y-2*k-2*i)^(z/2);
end
end
s
When I type Sum2(5,3,2) it gives me an appropriate output
but then I have the script
function sum = Sum3(x,y,z)
s = 0;
for i=0:min(x,y)
s = s + (-1)^k * QuantumDimension(2*x-2*i, 2*y-2*i) * Twist(2*x-2*i,2*y-2*i)^(z/2);
end
end
s
And when I type Sum3(5,2,1) I get:
Error: File: Sum3.m Line: 8 Column: 1
This statement is not inside any function.
(It follows the END that terminates the definition of the function "Sum3".)
What the heck?!?!? The placement of s in the script is completly similar to the function Sum2... What is going on here!! Thanks
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!