%% Preserve 3-D MATLAB Array
% This example shows how a C function changes the dimensions of a MATLAB array, and how to restore its shape.
% Load the library.

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

%
% Create a 2-by-5-by-2 input array and display its dimensions.

vin = reshape(1:20,2,5,2);
vs = size(vin)

%
% Call multDoubleArray to multiply each element. Display the dimensions of the output.

vout = calllib('shrlibsample','multDoubleArray',vin,20);
size(vout)

%
% Restore the original shape.

vout = reshape(vout,vs);
size(vout)

% Copyright 2015 The MathWorks, Inc.