MATLAB: Can I make a counter in App Designer

app designercounters

Hi, I'm trying to make an app using App Designer that shows different phases of processing on a signal. The user will be able to configure radio button selections and drop down values such that a specific signal will be chosen when the user clicks the Run button.
The idea is that after the user configures for a specific signal and hits the Run button, the signal is shown before it is processed. Then I wish to use (arrows or) a Back button and a Forward button to show how the signal transforms during processing for fixed increments of time.
The way I hoped to accomplish this is by using a counter variable, Cnt, to increment or decrement based on if the Back or Forward button is clicked respectively.
This is a test app I've been trying. It shows either a vertical line or horizontal line based on if A or B is chosen respectively, and the Run button is clicked. The Back and Forward Button respectively decreases or increases the number of lines horizontally or vertically based on if it is A or B chosen.
This is my callback code for the Run Button:
Ch = app.Choices.SelectedObject;
app.UIAxes.XAxis.Limits = [0 100];
app.UIAxes.YAxis.Limits = [0 100];
switch Ch
case app.Achoice
a = [10 10 10 10 10];
b = [5 30 55 80 95];
plot(app.UIAxes,a,b)
case app.Bchoice
d = [10 10 10 10 10];
e = [5 30 55 80 95];
plot(app.UIAxes,e,d)
end
For the Forward button callback:
Ch = app.Choices.SelectedObject;
app.UIAxes.XAxis.Limits = [0 100];
app.UIAxes.YAxis.Limits = [0 100];
app.cnt = app.cnt + 1;
if Ch == app.AChoice
if app.cnt == 1
a = [10 10 10 10 10];
b = [5 30 55 80 95];
plot(app.UIAxes,a,b)
hold on
a1 = [30 30 30 30 30];
plot(app.UIAxes,a1,b)
elseif app.cnt == 2
a = [10 10 10 10 10];
b = [5 30 55 80 95];
plot(app.UIAxes,a,b)
hold on
a1 = [30 30 30 30 30];
plot(app.UIAxes,a1,b)
hold on
a2 = [50 50 50 50 50];
plot(app.UIAxes,a2,b)
elseif app.cnt == 3
a = [10 10 10 10 10];
b = [5 30 55 80 95];
plot(app.UIAxes,a,b)
hold on
a1 = [30 30 30 30 30];
plot(app.UIAxes,a1,b)
hold on
a2 = [50 50 50 50 50];
plot(app.UIAxes,a2,b)
hold on
a3 = [70 70 70 70 70];
plot(app.UIAxes,a3,b)
elseif app.cnt == 4
a = [10 10 10 10 10];
b = [5 30 55 80 95];
plot(app.UIAxes,a,b)
hold on
a1 = [30 30 30 30 30];
plot(app.UIAxes,a1,b)
hold on
a2 = [50 50 50 50 50];
plot(app.UIAxes,a2,b)
hold on
a3 = [70 70 70 70 70];
plot(app.UIAxes,a3,b)
hold on
a4 = [90 90 90 90 90];
plot(app.UIAxes,a4,b)
else
errordlg('','Too High')
end
elseif Ch == app.BChoice
if app.cnt == 1
d = [10 10 10 10 10];
e = [5 30 55 80 95];
plot(app.UIAxes,e,d)
hold on
d1 = [30 30 30 30 30];
plot(app.UIAxes,e,d1)
elseif app.cnt == 2
d = [10 10 10 10 10];
e = [5 30 55 80 95];
plot(app.UIAxes,e,d)
hold on
d1 = [30 30 30 30 30];
plot(app.UIAxes,e,d1)
hold on
d2 = [50 50 50 50 50];
plot(app.UIAxes,e,d2)
elseif app.cnt == 3
d = [10 10 10 10 10];
e = [5 30 55 80 95];
plot(app.UIAxes,e,d)
hold on
d1 = [30 30 30 30 30];
plot(app.UIAxes,e,d1)
hold on
d2 = [50 50 50 50 50];
plot(app.UIAxes,e,d2)
hold on
d3 = [70 70 70 70 70];
plot(app.UIAxes,e,d3)
elseif app.cnt == 4
d = [10 10 10 10 10];
e = [5 30 55 80 95];
plot(app.UIAxes,e,d)
hold on
d1 = [30 30 30 30 30];
plot(app.UIAxes,e,d1)
hold on
d2 = [50 50 50 50 50];
plot(app.UIAxes,e,d2)
hold on
d3 = [70 70 70 70 70];
plot(app.UIAxes,e,d3)
hold on
d4 = [90 90 90 90 90];
plot(app.UIAxes,e,d4)
else
errordlg('','Too High')
end
else
errordlg('','Stuff')
end
Similar code is written for the Back button. I made the counter variable, cnt, a private property. Now the error I receive for my file, Arrow_Try.mlapp is: No appropriate method, property, or field 'AChoice' for class 'Arrow_try'.
Please help me. I have never used a counter before in App Designer.

Best Answer

The error message you've shown doesn't appear to be connected with 'cnt' at all. It's complaining that it doesn't recognzie "app.AChoice" . Check that app.AChoice returns what it's supposed to.