sum with matlab code
- by user27089
i need help it is only put sum in a code line if you can understand
in below i have a code
in this line below -> X(i,k+1) = X(i,k) + (( X(j,k)-X(i,k)));
i want to change it as: X(i,k+1) = X(i,k) + sum(( X(j,k)-X(i,k)));
briefly how can I put sum on the code line
clear;rand('state', 1);
global xLocation;
N = 4;
xLocation = rand(N,1);
t=2;k=1;X=[N,t];
for i=1:N
X(i,1)=xLocation(i);
end
while( k < t )
for i = 1 : N
for j = 1 : N
X(i,k+1) = X(i,k) + (( X(j,k)-X(i,k)));
end
end
k = k + 1;
end