Explore libstruct Objects
This example shows how to display information about and modify a libstruct object,c_struct
.
Load theshrlibsample
library containing thec_struct
definition.
ifnot(libisloaded('shrlibsample')) addpath(fullfile(matlabroot,'extern','examples','shrlib')) loadlibrary('shrlibsample')end
Create thelibstruct
object. Objectsc
is an instance of a MATLAB class calledlib.c_struct
.
sc = libstruct('c_struct')
sc = lib.c_struct
Set structure field values.
set(sc,'p1', 100,'p2',150,'p3',200)
Display field values.
get(sc)
p1: 100 p2: 150 p3: 200
Modify values using MATLAB field structure syntax.
sc.p1 = 23; get(sc)
p1: 23 p2: 150 p3: 200