用matlab编写一个累加和的程序,急~~~在线等

来源:百度知道 编辑:UC知道 时间:2024/06/27 12:33:15
用matlab编写一个累加和的程序
不是,有55个数据(N1,N2,N3,…,N55),要对这几个数据进行一阶累加,得到数据(N1,N1+N2,N1+N2+N3,…,N1+N2+…+N55)
程序运行不了,提示为:error_msg : maple: directory does not exist

【补充】
clc;clear
x=sym('[N1 N2 N3 N4 N5 N6]')
n=length(x);
temp=0;
for k=1:n
temp=temp+x(k);
s(k)=temp;
end
s

结果:
s =

[ N1, N1+N2, N1+N2+N3, N1+N2+N3+N4, N1+N2+N3+N4+N5, N1+N2+N3+N4+N5+N6]

【以前的】
是这个意思吗?
clc;clear
x=1:10
sum(x)

结果:
x =

1 2 3 4 5 6 7 8 9 10

ans =

55

x=[1 3 2 4 5 1 8 9]

x =

1 3 2 4 5 1 8 9

>> cumsum(x)

ans =

1 4 6 10 15 16 24 33