How do I change the sample rate of the animated line
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I've got an arduino that is sending a signal to Matlab. The current code I have plots the signal but it's obscured due to the sampling rate. How do I implement or change the sampling rate. This is the code I use to obtain data from the arduino:
figure
h = animatedline;
ax = gca;
ax.YGrid = 'on';
ax.YLim = [0 2];
stop = false;
startTime = datetime('now');
while ~stop
v = readVoltage(a,'A5');
output = v
time = datetime('now') - startTime;
addpoints(h,datenum(time),output)
ax.XLim = datenum([time-seconds(50) time]);
datetick('x','keeplimits')
drawnow
stop = readDigitalPin(a, 'A6');
end
0 comentarios
Respuestas (1)
Walter Roberson
el 30 de Oct. de 2018
You need to redesign your code to overcome this. You need to create an arduino sketch or c/c++ program that does nothing other than to reads the pins and send the results to MATLAB.
Note that if you are using the USB port to send the data then it is limited in the number of transactions per second. https://www.mathworks.com/matlabcentral/answers/400467-what-is-matlab-s-sampling-rate-through-arduino-analog-input#comment_567391
2 comentarios
Walter Roberson
el 8 de Nov. de 2018
You do not set t(i) until after you addpoint trying to use its value.
Ver también
Categorías
Más información sobre Animation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!