Skip to content

Instantly share code, notes, and snippets.

@GiovanniBalestrieri
Created July 30, 2015 18:25
Show Gist options
  • Save GiovanniBalestrieri/a87b41060869e58d6f9d to your computer and use it in GitHub Desktop.
Save GiovanniBalestrieri/a87b41060869e58d6f9d to your computer and use it in GitHub Desktop.
Matlab Snippet - Saving CSV data from Matlab to Arduino
%% Ask desired Sample Rate in Hz
rate=input('Enter the sampleRate in Hz. Max 500Hz. Non sgravare... ');
delay = 1/rate;
str = sprintf('SampleRate fixed to: %f.', delay);
disp(str);
%% Initializinig rolling plot
buf_len = rate;
index = 1:buf_len;
% create variables for the Xaxis
gxdata = zeros(buf_len,1);
gydata = zeros(buf_len,1);
gzdata = zeros(buf_len,1);
if recording
resp = input('Press r to record 2 seconds of data','s');
if (strcmp(resp,'r'))
disp('Record!');
record = true;
numberOfSamples = 0;
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment