Main Content

setdatatype

Class: lib.pointer
Namespace: lib

Initialize type and size of lib.pointer object

Syntax

setdatatype(h,type,sizeD1,...,sizeDn)

Description

setdatatype(h,type,sizeD1,...,sizeDn) sets data type to lib.pointer h.

Input Arguments

expand all

lib.pointer object, specified as a handle.

Data type, specified as a character vector. Use libfunctions to get type information about functions in a shared C library.

Size of each dimension, specified as double.

Examples

expand all

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
ans = 495

Version History

Introduced before R2006a