The Matlab script is working, but I need a little help on a detail.
I am sending data from the microcontroller to the PC using UART (RS232) evey 100 ms (it can be configured). I'm sending two integer values.
The matlab script reads both values correctly and stores them in 2 vectors, one for each value read. The vectors are growing in size over time, and as they grow I want to update my plot. (Plot as two series against time).
The thing is I can update only one graph in the plot using this:
set(plotHandle, 'YData', voltage, 'XData', time);
I have tried this to update both:
plot(axesHandle,time,voltage,time,target,'LineWidth',2);
where time, voltage and target are the 3 series. And I want to plot voltage and target as two series against time.
But it is too slow re-plotting everything, I have a major delay. The "set" method works fast but only for one series against time.
This is the code if you want to look into it:
https://github.com/xkyve/mobility/blob/master/matlab/real_time_data_plot.m