How to compare number in Edit Field to number in Ui Table, then checking box?
Afficher commentaires plus anciens
Hi! I am trying to take the value displayed in the numeric edit field " app.Out1"(an output from a simulink model that reads barcodes) and compare it to a column in "app. UITable4" (filled with data from an excel file) to make it check the box in that table (so switching its current logic of FALSE to TRUE if the barcode matches an item in the table.
Below is the current code I have that currently just displays the scanned barcode in the "app.Out1" edit field.
% Button pushed function: ScanButton_2
function ScanButton_2Pushed(app, event)
% opens barcode scanner
simFile = 'demoimaqsl_barcoderecognition.slx';
set(app.edit_SelectedMDLFile2,'Value',simFile);
app.Out2.Tag = 'Out1';
simulinkModel = app.edit_SelectedMDLFile2.Value;
simulinkModel = extractBefore(simulinkModel,'.');
disp('########## Opening Simulink-Model ##########');
fprintf('Simulink-Model: %s.mdl\n', simulinkModel)
open_system(simulinkModel);
set_param(simulinkModel,'SimulationCommand','start');
figure(app.UIFigure)
% logic to match the barcode column with the output of the barcode
% scanner --> match = checkbox is filled, unmatched = empty
% checkbox
% meant to be the index of all the values the barcode column
% itembarcode = readtable(string(app.UITable4.Data{row,3}(1)), "Sheet", 2, "Range" , 4);
% if app.Out1.Value == itembarcode
% something to check box of the associated item, based on barcode in app.Out1
end
Here is my theoretical attempt/idea to index the column with barcodes. I have yet to workout how I could possibly change the logic of the excel file to check the box associated with that barcode value.
% logic to match the barcode column with the output of the barcode
% scanner --> match = checkbox is filled, unmatched = empty
% checkbox
% meant to be the index of all the values the barcode column
% itembarcode = readtable(string(app.UITable4.Data{row,3}(1)), "Sheet", 2, "Range" , 4);
% if app.Out1.Value == itembarcode
% something to check box of the associated item, based on barcode in app.Out1
Réponse acceptée
Plus de réponses (1)
Reshma Nerella
le 15 Fév 2021
Hi,
In this line of code in the updated code
UITABLE4DATA(rowindex,1) = {1} ;
It replaces the content of cell with value '1'.
If you want to check/uncheck the checkbox, use
UITABLE4DATA(rowindex,1) = {true} ; % for checking
UITABLE4DATA(rowindex,1) = {false} ; % for unchecking
Hope this helps!
1 commentaire
Shalaka Kollerkandy
le 15 Fév 2021
Catégories
En savoir plus sur App Building dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!