%% Convert MATLAB Array to C-Style Dimensions
% This example shows how to pass data stored columnwise in a MATLAB array to a C function that assumes a row-by-column format.
% Load the library containing the print2darray function.

if not(libisloaded('shrlibsample'))
    addpath(fullfile(matlabroot,'extern','examples','shrlib'))
    loadlibrary('shrlibsample')
end

%
% Create a MATLAB array with 4 rows and 3 columns.

m = reshape(1:12,4,3)

%
% Display the values. The first column is [1 4 7 10] instead of [1 2 3 4].

calllib('shrlibsample','print2darray',m,4)

%
% Transpose m to get the desired result.

calllib('shrlibsample','print2darray',m',4)

% Copyright 2015 The MathWorks, Inc.