Code covered by the BSD License  

Highlights from
xPC Target Data Logging Methodologies

image thumbnail

xPC Target Data Logging Methodologies

by

 

12 Nov 2007 (Updated )

Describes several methods available to log and access signal data with xPC Target.

OutPortDataLoggingDemo.m
% OUTPORTDATALOGGINGDEMO - Demonstrates xPC Target Data Logging Using An Outport
%
%    This M-file was created in support of the xPC Target Application Note 
%    (xPCTAN-0100): "xPC Target Data logging Methodologies"

% Open, build, and run model.
open_system('sosModel2');                   % Open the model
set_param('sosModel2','RTWVerbose','off');  % Configure RTW for a non-Verbose build
rtwbuild('sosModel2');                      % Build and download to the target PC
close_system('sosModel2',0);                % Close the model
tg = xpc;                                   % Create an xPC Target Object
start(tg);                                  % Start xPC Target Object (run the model)

% Wait until model has finished running.
while ~strcmpi(tg.Status,'stopped');        % Is the run complete?       
end;

% Get data.
opTime = tg.TimeLog;                        % Get outport time log
opData = tg.OutputLog;                      % Get outport data log

% Plot and save data.
plot(opTime,opData); grid on;               % Plot the data
title('DEMO: Outport Data Logging');      
save sosOPDataLog.mat opTime opData;        % Save the data
disp('Data saved in: sosOPDataLog.mat')

Contact us