from rowmatrix indexing by Shoeb Temrikar
index matrices in rowwise fashion

rowmatrix.m
%
%{
matlab provides matrix indexing in coloumwise format.
using this program one can index matrices in rowwise fashion
%}

% u can take any matrix, i have just taken an exanple

A=[1 2 3
    4 5 6
    7 8 9]


a=A';
a=a(:);
a=a'

% now a(1) will return 1 , a(2) will return 2, a(3) will return 3 and so on...

% to check how matlab index matrix execute: m=A(:); m=m'
% here m(1) will return 1, m(2) will return 4, m(3)=7, m(4)= 2 and so on... 

Contact us at files@mathworks.com