Explore libstruct Objects
This example shows how to display information about and modify a libstruct object, c_struct.
Load the shrlibsample library containing the c_struct definition.
if not(libisloaded('shrlibsample')) addpath(fullfile(matlabroot,'extern','examples','shrlib')) loadlibrary('shrlibsample') end
Create the libstruct object. Object sc is an instance of a MATLAB® class called lib.c_struct.
sc = libstruct('c_struct')sc =
c_struct with properties:
p1: 0
p2: 0
p3: 0
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