Skip to content

Instantly share code, notes, and snippets.

@AlexFWulff
Created November 11, 2019 00:35
Show Gist options
  • Save AlexFWulff/e592cb28ec0290647c22f3a947b036e9 to your computer and use it in GitHub Desktop.
Save AlexFWulff/e592cb28ec0290647c22f3a947b036e9 to your computer and use it in GitHub Desktop.
if ~exist('port','var')
ports = serialportlist;
port = serialport(ports(end),115200);
end
configureTerminator(port,"CR");
x = input('Sample Name to Write: \n','s');
count = 1; sample_len = 500; plotWinSize = 100;
data = NaN(1,sample_len); plot(data)
port.flush;
while count <= sample_len
data(count) = port.readline;
count = count + 1;
plot(data)
xlim([max(0,count-plotWinSize) max(plotWinSize,count)])
end
fid = fopen(x, 'wt');
fprintf(fid, '%d\n',data);
fclose(fid);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment