%% Convert Subscripts to Linear Indices for Matrix
% The mapping from subscripts (indexing by position) to linear indices for a 3-by-3 matrix can be illustrated as in the following.
%
% Specify the row and column subscripts in a 3-by-3 matrix. Convert the subscripts to linear indices.

row = [1 2 3 1];
col = [2 2 2 3];
sz = [3 3];
ind = sub2ind(sz,row,col)

%
% Copyright 2019 The MathWorks, Inc.