필터 지우기
필터 지우기

User input folder path in App Designer with multiple tables

조회 수: 13 (최근 30일)
Emily
Emily 2022년 6월 23일
편집: Jon 2022년 6월 24일
First time using this feature. I'm trying to have the user input their folder path and will display the calculation based on it.
I have the calculation code on a seperate file that is called when the calculate button is pressed.
function calculation(folderpath)
But other than that I'm not sure how to have
  1. what the user input = folderpath so the function can be run
  2. how to display the data in the correct table location
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2022년 6월 23일
@Emily - how does the user enter the folder path? Should they use uigetdir to populate that path text control?
Emily
Emily 2022년 6월 23일
편집: Emily 2022년 6월 23일
They just copy/paste the folder path directly into the text box.

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

답변 (1개)

Jon
Jon 2022년 6월 23일
You need to define a value changed callback function for each Edit Field, something like this for the first one, and then similar for the second one, except change the names appropriately, e.g. app.EditField -> app.EditField2
, app.UITable.Data ->app.UITable2.Data
% Callbacks that handle component events
methods (Access = private)
% Value changed function: EditField
function EditFieldValueChanged(app, event)
% get the folder path that the user entered
folderpath = app.EditField.Value;
% calculate the data using the data in this folder
data = calculation(folderpath)
% display the data in the appropriate table
app.UITable.Data = data
end
  댓글 수: 3
Emily
Emily 2022년 6월 23일
Hi, I tried out this method and it's giving me some errors.
Error using calculation
Too many output arguments
Error sandbox/ButtonPushed
data=calculation(folderpath);
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback
Error while evaluating Button PrivateButtonPushedFcn
I tested out the calculation code again and it seems to be working and printing the cell arrays properly.
Jon
Jon 2022년 6월 24일
편집: Jon 2022년 6월 24일
The error message is telling you that your function, calculation, is not returning any output arguments, but you try to assign a value to the output, in your line
data=calculation(folderpath);
Please check that in your code for calculation that the first line assigns an output argument to the result of the calculation, that is the for example:
function outData = calculation(folderpath)
inData = readmatrix(fullfile(folderpath,'myData.csv'))
outData = inData*2; % just for example
end
If that doesn't fix your problem, please attach your code along with any necessary files to run it and I will see what is going on.

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

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by