Get user input in app designer using toggle button group
7 views (last 30 days)
Show older comments
Hello,
I've recently started using the app designer in Matlab and I'm trying to get user input in my app for the following:
I have a 3D-matrix with multiple datafiles that I want to judge for their quality and exclude if the quality is not good enough.
The analysis is started by clicking the 'Start analysis' button and subsequently, the first datafile is plotted. I plot the data in 2 graphs and based on these I want to either keep the data or exclude it and continue to the next datafile in the matrix. I thought of using a toggle button group for this, see below for how this would look.
I had previously written part of the script in a regular Matlab script of which I copied a part below to illustrate what my intention is. However, in the app I would like the user to be able to click the 'Keep data' box or 'Exclude data' box and consequently have the data either put in the data matrix or excluded_data matrix.
With my limited experience in app designer, I haven't been able to figure out how to implement a click on the toggle button in the start analysis. I have tried to watch some youtube video's/browsed the MathWorks community but it didn't get me very far yet.
Can anyone help with how I would be able to do this or give me some tips where to look for more information?
data = zeros(size(alldata));
data_filename = cell(size(allCCNames));
excluded_data = zeros(size(alldata));
excluded_filename = cell(size(allCCNames));
for z = 1:size(alldata,2)
for i = 1:12
plot(app.UIAxes,alldata(:,z,i))
hold(app.UIAxes,'on')
end
for i = 13:50
plot(app.UIAxes2,alldata(:,z,i))
hold(app.UIAxes2,'on')
end
%Matlab code outside app designer
choice = menu('Is the quality of the recording good enough?','Yes','No');
if choice == 1;
data(:,z,:) = alldata(:,z,:);
data_filename(1,z) = allCCNames(z);
elseif choice == 2;
excluded_data(:,z,:) = alldata(:,z,:);
excluded_filename(1,z) = allCCNames(z);
end
% Clear figures for next plot in app designer
hold(app.UIAxes,'off')
hold(app.UIAxes2,'off')
end
0 Comments
Accepted Answer
Sam
on 6 Jul 2021
Create two seperate MATLAB functions, one for keeping the data and other for excluding the data. Something similar to:
function keepdata()
data(:,z,:) = alldata(:,z,:);
data_filename(1,z) = allCCNames(z);
end
function excludedata()
%add relevant matlab commands here
end
More Answers (0)
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!