Code covered by the BSD License  

Highlights from
xPC File Scope Tools

image thumbnail

xPC File Scope Tools

by

 

26 Jul 2007 (Updated )

Functions to easily save xPC File Scope data to the target PC as MAT files.

xpcdata2mat(xpcdata)
function [Data,Time,Signals] = xpcdata2mat(xpcdata)
% xpcdata2mat - Convert xpcdata format to a matrix
% -------------------------------------------------------------------------
% Abstract: This function converts the xpcdata structure format to a MATLAB
% matrix. It optionally returns a list of the signal names.
%
% Syntax:
%       Data = xpcdata2mat(xpcdata)    %time vector is first Data column
%       [Data,Time] = xpcdata2mat(xpcdata)   %time vector is separate
%       [Data,Time,Signals] = xpcdata2mat(xpcdata)  %includes signal names
%
% Inputs:
%           xpcdata - xpcdata structure generated from getxpcFileData.m
%
% Outputs:
%           Data - matrix of output data (may include time)
%           Time - time vector
%           Signals - cell array of signal names
%
% Examples:
%           none
%
% Notes: none
%

% Copyright 2007 - 2009 The MathWorks, Inc.
%
% Auth/Revision:
%   The MathWorks Consulting Group
%   $Author: rjackey $
%   $Revision: 10 $  $Date: 2007-07-26 15:56:29 -0400 (Thu, 26 Jul 2007) $
% -------------------------------------------------------------------------

% Initialize the data vector
Data = [];

% Import the time vector
Time = xpcdata.time;
Signals{1} = 'time';

% Get the signal names stored in this structure
SigNames = xpcdata.signals;

% Import each data into a matrix column
for i=1:length(SigNames)

    Data(:,end+1) = xpcdata.(SigNames{i}); %#ok<AGROW>
    Signals{end+1} = SigNames{i}; %#ok<AGROW>

end

% Combine time and data if only one output argument
if nargout < 1
    Data = [Time, Data];
end

Contact us