Help debugging real time plotting issues
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Harini
el 16 de Oct. de 2023
Comentada: Harini
el 17 de Oct. de 2023
I am plotting Raw EMG data in MATLAB. Here is the code I am using for plotting after creating time vector.
% Function to update the real-time plots
function updatePlots(t, data)
if isvalid(fig)
% Create time vectors
tData = (1:length(data)) / samplingRate; % Create a time vector for the raw data
% Plot raw data
addpoints(h1, tData , data);
% Set the X-axis limits based on the time window
xlim(ax1, [t - timeToEdit.Value / 1000, t]);
drawnow limitrate;
end
end
end
Why does the plot have lines connected to the first datapoint. How do I go about debugging this
0 comentarios
Respuesta aceptada
Voss
el 16 de Oct. de 2023
"Why does the plot have lines connected to the first datapoint[?]"
Because tData(1) is always 1/samplingRate.
I guess you should be using t in your calculation of tData, but I can't say for sure how because I don't know what t represents. I gather it's a scalar number since otherwise the call to xlim would produce an error. You use t as the upper x-limit of your axes, so is it the end time in seconds of the new data? If so then maybe something like this:
tData = t - (numel(data)-1:-1:0) / samplingRate;
Más respuestas (0)
Ver también
Categorías
Más información sobre Arduino Hardware 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!