www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ShrlibExploreLibstructObjectsExample.m
%% 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') %% % Set structure field values. set(sc,'p1',100,'p2',150,'p3',200) %% % Display field values. get(sc) %% % Modify values using MATLAB field structure syntax. sc.p1 = 23; get(sc) %% %