More like this perhaps
N=10; % 50;
A=gallery('poisson',N);
n=size(A,1);
xs=ones(n,1);
b=A*xs(:);
MaxIter=10*n;
TOL=1.e-4;
t=cputime;
[x]=myJacobi(A,b,MaxIter,TOL,n); % Jacobi example
mycput = cputime - t;
relerr = norm(xs-x)/norm(xs);
fprintf('size(A,1) = %d, relerr = %8.5e\n',n, relerr);
fprintf('time = %8.5e\n', mycput);
function [x] = myJacobi(A,b,MaxIter,TOL,n)
%Jacobi Method
x=zeros(n,1);
k=1;
err = 1;
while k<=MaxIter && err>TOL
for i=1:n
x(i)=(b(i)-A(i,[1:i-1,i+1:n])*x([1:i-1,i+1:n]))/A(i,i);
end
err = norm(A*x-b)/norm(b);
k=k+1;
end
disp(k)
end
Note: you hadn't implemented any calculation for info and relres, so they've been removed in the version here.