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.

HostScopeDataLoggingDemo.m
% HOSTSCOPEDATALOGGINGDEMO - Demonstrates xPC Target Data Logging Using a Host Scope
%
%    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('sosModel3');                   % Open the model
set_param('sosModel3','RTWVerbose','off');  % Configure RTW for a non-Verbose build
rtwbuild('sosModel3');                      % Build and download to the target PC
close_system('sosModel3',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.
sc=getscope(tg,2);                          % Get handle to host scope (Id: 2)
hsTime = sc.Time;                           % Get host scope time log
hsData = sc.Data;                           % Get host scope data log

% Plot and save data.
plot(hsTime,hsData); grid on;               % Plot the data
title('DEMO: Host Scope Data Logging');  
save sosHSDataLog.mat hsTime hsData;        % Save the data
disp('Data saved in: sosHSDataLog.mat')

Contact us