having an issue in App Designer clearing plots

조회 수: 6 (최근 30일)
J. Webster
J. Webster 2016년 4월 13일
댓글: Matthew Ward 2021년 1월 14일
In the application I'm developing, and I'd like to make it so that the data that is plotted will be based on which checkboxes are checked. The block of code that does this is below. My problem is that the clf doesn't clear the figure. Each time this code runs, then I get a new set of data plotted on top of the old set of data.
Am I doing something wrong?
clf(app.UIAxesDay);
hold(app.UIAxesDay, 'on');
if app.CheckBoxMPFV.Value
plot(app.UIAxesDay, walknum, mpfv,'-o' );
end
if app.CheckBoxMST.Value
plot(app.UIAxesDay, walknum, mst, '-o' );
end
if app.CheckBoxMSD.Value
plot(app.UIAxesDay, walknum, msd, '-o' );
end
ylim(app.UIAxesDay, [0 7]);
hold(app.UIAxesDay, 'off');

채택된 답변

Mike Garrity
Mike Garrity 2016년 4월 13일
Well, clf probably isn't what you want anyways. It's job is to remove everything from a figure, and it sounds like you have checkboxes in the figure. It would also delete the axes that you've named UIAxesDay, and you'd need to create a new one.
I think that what you probably want is cla. It's job is to remove everything from an axes. You'd use it like this:
cla(app.UIAxesDay)
  댓글 수: 3
Kristin Schall - van Bellen
Kristin Schall - van Bellen 2020년 7월 30일
What can you do, if cla is not working?
Matthew Ward
Matthew Ward 2021년 1월 14일
app.UIAxes.cla works for me, but does not clear patch objects.

댓글을 달려면 로그인하십시오.

추가 답변 (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