%% Add Values of Fields in Structure
% This example shows how to pass a MATLAB structure to the function, addStructFields.
% Create and initialize structure sm. Each field is of type double.

sm.p1 = 476;
sm.p2 = -299;
sm.p3 = 1000;

%
% Load the library containing the addStructFields function.

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

%
% Call the function. MATLAB automatically converts the fields of structure  sm to the library definition for c_struct.

calllib('shrlibsample','addStructFields',sm)

% Copyright 2015 The MathWorks, Inc.