Filter löschen
Filter löschen

In AppDesigner, how to input a CSV file using a checkbox?

4 Ansichten (letzte 30 Tage)
Scotty Mac
Scotty Mac am 7 Jul. 2023
Kommentiert: Scotty Mac am 10 Jul. 2023
I would like add a checkbox to my App Designer GUI, so that when checked, it opens a file explorer field (similar to a load button) and imports a selected CSV file.
So ulimately, when I hit 'calculate' on my GUI, if the checkbox is selected, use the imported CSV in my calculations, otherwise when not selected, it doesn't use the CSV data. Basically an 'Include a CSV datafile in calcultions' checkbox...
What is the best way to accomplish what I am trying to do?
Do I need to import that CSV data to a variable to store it, then check if the checkbox is selected before calculating?
Thanks in advance.

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 7 Jul. 2023
Bearbeitet: Cris LaPierre am 7 Jul. 2023
Looks like you might want to use uigetfile in the checkbox callback function.
  1 Kommentar
Scotty Mac
Scotty Mac am 10 Jul. 2023
Here is my code. Thanks @Cris LaPierre.
% Value changed function: InclCalibrationFileCheckBox
function InclCalibrationFileCheckBoxValueChanged(app, event)
value = app.InclCalibrationFileCheckBox.Value;
if (value == 1) % Checkbox is Checked
% Allow the user to select any CSV file
[file,path] = uigetfile('*.csv');
if isequal(file,0)
% User selected cancel
return;
else
csvData = readmatrix(file);
end
end
%% Placeholder for how to add csvData to the calculation.
end
end

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by