Last active
August 29, 2015 14:10
-
-
Save AllanLRH/850f7aa6decd5eac329d to your computer and use it in GitHub Desktop.
Read Picoscope 6 csv files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% 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