%-- Simple Matrix-Vector multiply routine in Matlab --%
% NOTE: there are much more efficient ways to do this
%  same thing in Matlab. The below is set up like a C
%  or Fortran program should be made.
%-----------------------------------------------------%

% Matrix Size
N=3;

%-- Set up A matrix and x vector --%
for i=1:N
   for j=1:N
      A(i,j)=(i-1)*(j-2)+1.0;
   end
   x(i)=1.0;
end

%-- Print out A matrix --%
A

%-- Matrix multiply --%
for i=1:N
   sum=0.0;
   for j=1:N
      sum=sum+A(i,j)*x(j);
   end
   b(i)=sum;
end
b