sum with matlab code

Posted by user27089 on Programmers See other posts from Programmers or by user27089
Published on 2012-06-20T21:03:14Z Indexed on 2012/06/20 21:23 UTC
Read the original article Hit count: 135

Filed under:
|
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

© Programmers or respective owner

Related posts about algorithms

Related posts about array