-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathimport_PosSci.m
29 lines (23 loc) · 1.13 KB
/
import_PosSci.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function [frame,gazex,gazey] = import_PosSci(filename, startRow, endRow)
%Matlab auto-generated script to import Positive Science HMET data files
%NOTE: User must delete the header from the text file--this script does not
%deal with header information. See example data file for correct format.
delimiter = ' ';
if nargin<=2
startRow = 1;
endRow = inf;
end
formatSpec = '%f%*s%*s%*s%*s%f%f%*s%*s%*s%*s%*s%*s%[^\n\r]';
fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', delimiter, 'MultipleDelimsAsOne', true, 'EmptyValue' ,NaN,'HeaderLines', startRow(1)-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
for block=2:length(startRow)
frewind(fileID);
dataArrayBlock = textscan(fileID, formatSpec, endRow(block)-startRow(block)+1, 'Delimiter', delimiter, 'MultipleDelimsAsOne', true, 'EmptyValue' ,NaN,'HeaderLines', startRow(block)-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
for col=1:length(dataArray)
dataArray{col} = [dataArray{col};dataArrayBlock{col}];
end
end
fclose(fileID);
frame = dataArray{:, 1};
gazex = dataArray{:, 2};
gazey = dataArray{:, 3};