필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
Scotty Mac
Scotty Mac 2023년 7월 7일
댓글: Scotty Mac 2023년 7월 10일
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.

채택된 답변

Cris LaPierre
Cris LaPierre 2023년 7월 7일
편집: Cris LaPierre 2023년 7월 7일
Looks like you might want to use uigetfile in the checkbox callback function.
  댓글 수: 1
Scotty Mac
Scotty Mac 2023년 7월 10일
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

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by