App Designer Dataleak/Overflow

1 次查看(过去 30 天)
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 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by