Documentation Center

  • Trial Software
  • Product Updates

setdatatype

Class: lib.pointer
Package: lib

Initialize type and size of lib.pointer object

Syntax

setdatatype(h,type,size)

Description

setdatatype(h,type,size) sets data type, type, of size, to lib.pointer, h.

Input Arguments

expand all

hlib.pointer object.handle

lib.pointer object, specified as a handle.

type — Data typestring

Data type, specified as a string.

size — Sizedouble

Size, specified as double.

Examples

expand all

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

   495
Was this topic helpful?