필터 지우기
필터 지우기

Undefined variable in app designer when the variable called in external function

조회 수: 2 (최근 30일)
Below is the code in my first push button
[file,filepath,~]=uigetfile('*.xls*','Multiselect','on','Select Vos file');
app.filepath=fullfile(filepath,file);
app.filepathEditField.Value = app.filepath;
Below is the code in second push button where i am trying to call an external function when the second function is pushed
if(isempty(app.filepath))
f = uifigure;
uialert(f,'Please select all the files','Error');
else
process_function;
end
the two codes above were wrote in appdesigner meanwhile the process function is an .m file
function a = process_function
[~,filename,fileext]=fileparts(app.filepath);
end
But i get the error in app designer showing undefined function of app.filepath. I really have no idea how to solve this, hope someone can give the the solution. Thanks in advance.

채택된 답변

Dennis
Dennis 2019년 3월 8일
Your external function does not know which variables you use in your app. You need to pass them along. Try changing
else
process_function(app.filepath);
end
and
function a = process_function(filepath)
[~,filename,fileext]=fileparts(filepath);
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by