App Designer Dataleak/Overflow

조회 수: 4 (최근 30일)
Dylan Tarter
Dylan Tarter 2020년 2월 12일
답변: Dylan Tarter 2020년 2월 13일
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

채택된 답변

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by