可如下定义匿名函数f:f=@(x) sum(arrayfun(@(i) sum(x(1:i))^2,1:30))调用如:x=1:30;f(x)结果为:ans = 1428976再如: x=ones(1,30); f(x)ans = 9455
>> syms x i>> s1=symsum(x,1,i) s1 = (i*(i + 1))/2 >> s=symsum(s1,1,30) s = 4960