-
-
Save GiovanniBalestrieri/ab58330fc25d1b4f355b to your computer and use it in GitHub Desktop.
Matab Snippet - Saving CSV data from Arduino to Matlab
This file contains hidden or 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
fprintf(xbee,'M') ; | |
notArrived = false; | |
try | |
while (get(xbee, 'BytesAvailable')~=0 && ~notArrived) | |
% read until terminator | |
sentence = fscanf( xbee, '%s'); % this reads in as a string (until a terminater is reached) | |
if (strcmp(sentence(1,1),'A')) | |
notArrived = true; | |
%decodes "sentence" seperated (delimted) by commaseck Unit') | |
C = textscan(sentence,'%c %d %d %d %c','delimiter',','); | |
Wx = C{2}; | |
Wy = C{3}; | |
Wz = C{4}; | |
% [gx, gy, gz] = [x, y, z]; | |
gxdata = [ gxdata(2:end) ; double(Wx) ]; | |
gydata = [ gydata(2:end) ; double(Wy) ]; | |
gzdata = [ gzdata(2:end) ; double(Wz) ]; | |
numberOfSamples = numberOfSamples + 1 | |
end | |
end | |
catch exeption | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment