Skip to content

Instantly share code, notes, and snippets.

@AllanLRH
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AllanLRH/850f7aa6decd5eac329d to your computer and use it in GitHub Desktop.
Save AllanLRH/850f7aa6decd5eac329d to your computer and use it in GitHub Desktop.
Read Picoscope 6 csv files.
%% readPicoScopeCSV: Reads a picoscope csv file.
% Returns a matrix with [m N] matrix with [x, y1, y2, ... ym] as columns
% Output may be captured like: [x, y1, y2, ... ym] = readPicoScopeCSV('path/to/csv/file.csv')
function varargout = readPicoScopeCSV(csvFilePath)
data = csvread(csvFilePath, 3); % Three header lines
nColumns = size(data, 2);
if nargout == 1
varargout{1} = data;
return;
elseif nargout == nColumns
% Allow user to capture data as
varargout = cell(1, nColumns);
for ii = 1:nColumns
varargout{ii} = data(:, ii);
end
else
error('\n\tYou must capture the output with one or %d variables.\n\t(Because %d is the number of columns in this data file).\n', nColumns, nColumns)
end % if
end % function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment