这是我的意见:
x1=[1 2 3 4]
x2=[1 2 3 4 1]
x3=[ 1 2 3 4 5 6 ]
我想开发一个for
循环代码来计算此等式D = x1(i+1)-x1(i)
,例如:
for i:1:k % k is referring to matrix of x1, x2 and x3
for i=1:n % n is referring to number of element in matrix x1, x2 and x3
D= x1(i+1)-x1(i) % for k=2 i want to change x1 to matrix x2
end
end
任何人都可以帮我解决如何为我的问题编写正确的代码吗?我已经尝试了很多次,但失败了。