www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ShrlibSetSizeandTypeoflibpointerOutputVariableExample.m

    %% Set Size and Type of lib.pointer Output Variable  

%% 
% Load the |shrlibsample| library. 
if ~libisloaded('shrlibsample')
  addpath(fullfile(matlabroot,'extern','examples','shrlib'))
  loadlibrary('shrlibsample')
end  

%% 
% The |multDoubleRef| function takes a scalar value specified as |doubleptr|.
% Create variable |xp| as a |lib.pointer| object,
% and call the function. 
xp = libpointer('doublePtr',99);
[xobj,xval] = calllib('shrlibsample','multDoubleRef',xp);  

%% 
% To use the variable |xobj|, set its size and data type. 
setdatatype(xobj,'doublePtr',1,1)
xobj.Value