www.gusucode.com > simulink 案例源码程序 matlab代码 > simulink/StoreaStringinSimulationMetadataObjectofvdpSimulationExample.m

    %% Store a Character Vector in SimulationMetadata Object of vdp Simulation  
% Simulate the |vdp| model. Store a custom character vector 
% in the |SimulationMetadata|
% object that the |SimulationOutput| object contains.   

%% 
% Simulate the |vdp| model. Save the results of the |Simulink.SimulationOutput|
% object in |simout|. 
 open_system('vdp')
 simout=sim(bdroot,'ReturnWorkspaceOutputs','on');  

%% 
% Store a character vector to describe the simulation. 
simout=simout.setUserString('First Simulation');  

%% 
% Use |SimulationOutput.getSimulationMetadata| to retrieve the information
% you stored. 
mData=simout.getSimulationMetadata();
disp(mData.UserString)