How to update large data plot (collected over time), with multiple data series in MATLAP App?

4 Ansichten (letzte 30 Tage)
Hello,
So I have an app, where I am collecting external data from 16 different sources. This data is constantly being updated, and I would like to have some sort of plot to show this data over time.
In essence, I have 16 different data sets, each with a value, and a timestamp.I would like these data sets to be plotted as different data series. As the data is collected, I update my UI. Currently, when I am updating my UI, I am replotting the entire data set for each data set. This gets very slow at even small numbers of data (i.e. over 5 mintues of data collection, I need this to run for a week).
This is what I want my graph output to look like (here I only have 3 data series, for debugging and testing purposes).
This is how I am updating my UI (everytime a data value is collected):
...%Pseudo code
data = get_CV()
update_main_graph(measurement_graph,data)
...
%Update UI function
function update_main_graph(measurement_graph,data)
for ii = 1:numel(fieldnames(data)) %number of fields is the number of data sources = 16
%Plot each measurement on the graph
field_name = strcat("ring", int2str(ii));
if isempty(data.(field_name).timestamp) ~= 1
time_axis = datetime(data.(field_name).timestamp,'InputFormat','dd-MMM-yyyy HH:mm:ss');
data_axis = data.(field_name).analyzed;
scatter(measurement_graph, time_axis, data_axis);
hold(measurement_graph,'on')
pause(0.001)
end
end
hold(measurement_graph,'off')
end
As you can see, I am replotting ALL THE DATA each time.
I can't figure out a way just to plot the new collected data every time.
Does anyone have an idea how I can go about doing this? I would really like to have a visualization of the data while the data is collecting, but if this won't be feasible I'll make do.
Any advice is GREATLY appreciated!!

Antworten (1)

Mario Malic
Mario Malic am 21 Okt. 2020
Can you check if time_axis and data_axis contain all the data from the measurements? If yes, you can try this
scatter(measurement_graph, time_axis(end), data_axis(end)); % plots the last element
The issue might be with uifigure, since it can get slow. Try creating a figure() with axes() and do plotting on it, unfortunately it will be in a window outside the UIFigure from AppDesigner. Also 1 ms pause might be problematic with refreshing the window You can try as well
drawnow limitrate
  2 Kommentare
Mark Lepage
Mark Lepage am 21 Okt. 2020
Bearbeitet: Mark Lepage am 21 Okt. 2020
The problem with this approach is that currently, inside the for loop - the data is plotted in a different data series everytime the scatter() function is called. This is what I want, as I want each data set plotted in a different series.
However, with your method, each time the new last element is plotted, it creates a new data series...
What I need is a method to call on a specific data series and to continue to plot just on that data series, i.e. something like
for ii = 1:numel(fieldnames(data))
%Plot each measurement on the graph
field_name = strcat("ring", int2str(ii));
if isempty(data.(field_name).timestamp) ~= 1
time_axis = datetime(data.(field_name).timestamp,'InputFormat','dd-MMM-yyyy HH:mm:ss');
data_axis = data.(field_name).analyzed;
%% Here I call upon the data series, to continue plotting to it - which doesn't exist to my knowledge
scatter(measurement_graph, field_name_data_series, time_axis, data_axis);
hold(measurement_graph,'on')
end
Mario Malic
Mario Malic am 21 Okt. 2020
In scatter property list, there's XDataSource, XData, Y... and so on, maybe those properties would be of interest, combined with refreshdata.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Develop uifigure-Based Apps finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by