%function[accelX accelY accelZ] = 
clc
clear all
close all


% Name of file to read - file must have byte data

% SD Card directory
fileID = fopen('H:\01-Jun-2011-22-50-39_accelY.txt');

% Directory on computer - DOWNLOADS
%fileID = fopen('C:\Users\nraymond\Downloads\01-Jun-2011-01-00-30_accelZ.txt');

% Read the file, assuming signed 8 bit integers
A = fread(fileID);

% Close the file
fclose('all');

numSamples = length(A)/2;

%Data_byte = zeros(numSamples,2);
Data_double = zeros(uint8(numSamples),uint8(1));

index = 1;
for i=1:2:numSamples*2
    MyByteArray = [A(i) A(i+1)];
    MyByteArray = uint8(MyByteArray);
    MySingle = typecast(MyByteArray,'int16');
    accelDouble = double(MySingle)/100.0;
    
    Data_int16(index,1) = MySingle;
    Data_double(index) = accelDouble; % Double
    
    index = index + 1;
end

figure;
plot(Data_double)

