App Designer Dataleak/Overflow

4 Ansichten (letzte 30 Tage)
Dylan Tarter
Dylan Tarter am 12 Feb. 2020
Beantwortet: Dylan Tarter am 13 Feb. 2020
I've been working on an appdesigner project which requires constant polling of data and displaying the most recent values on a scrolling graph. I have accomplished this using the attached code, but the problem is as T->inf it becomes slower and laggier. I've double checked and the X and data arrays should stay consistently the same size so as time goes on the values of say X should change but never actually contain more than say 100 values. Maybe the implementation causes some sort of dataleak and its not getting rid of what is left over. Any insight would be appreciated.
For the code: new_V1/I1 and dataX are both initialized as empty arrays. The value coming is can change depending on what is inputted. Max Scroll is 10
function results = pollOutput(app)
%% get new data
new_V1 = app.VoltagekVEditField.Value;
new_I1 = app.CurrentmAEditField.Value;
%% update labels
app.XkVLabel.Text = strcat(num2str(new_V1),'kV');
app.XmALabel.Text = strcat(num2str(new_I1),'mA');
%% append new values to data display arrays
xl = length(app.dataX);
mxs = app.maxScroll;
if(xl > 0 && xl < mxs)
%disp('load');
app.dataX = [app.dataX app.dataX(xl)+1];
app.dataV1 = [app.dataV1 new_V1];
app.dataI1 = [app.dataI1 new_I1];
elseif(xl >= mxs)
%disp('scroll');
app.dataX = [app.dataX(end-mxs+1:end) app.dataX(xl)+1];
app.dataV1 = [app.dataV1(end-mxs+1:end) new_V1];
app.dataI1 = [app.dataI1(end-mxs+1:end) new_I1];
xlim(app.UIAxes,[app.dataX(1),app.dataX(end)]);
else
%disp('init');
app.dataX = 1;
app.dataV1 = [app.dataV1 new_V1];
app.dataI1 = [app.dataI1 new_I1];
end

Akzeptierte Antwort

Dylan Tarter
Dylan Tarter am 13 Feb. 2020
I found the answer myself. For these graphics they are axes so use:
"clear axes"
cla(app.my_axes)

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by