Load Text in Edit field AppDesigner

조회 수: 3 (최근 30일)
Daniel Boateng
Daniel Boateng 2019년 4월 17일
답변: ES 2019년 4월 17일
I designed a GUI in appdesigner where I can bush the button LOAD to load a file directly from my desktop. But I want the name of the file to appear in the Edit field. Is there anyway i can do it? I am new to appdesigner
Thank you
%% function for the load button.
function LOADButtonPushed(app, event)
[file,~] = uigetfile(['*.mat'],'Load File','MultiSelect', 'off');
if isequal(file,0)
disp('Nothing Selected')
else
try
app.Data = load(file);
Timestep= app.Data.Profile(1,:);
Power = app.Data.Profile(2,:);
plot(app.UIAxes,Timestep,Power)
catch
errordlg(['There was a problem loading the .mat',' file'],'Load Error!');
return;
disp(['User selected ',file]);
end
end
%% function for the EditField
function PROFILENAMEEditFieldValueChanged(app, event)
app.Data= app.PROFILENAMEEditField.Value

채택된 답변

ES
ES 2019년 4월 17일
You have to update the edit field value from the callback of the load button.
%% function for the load button.
function LOADButtonPushed(app, event)
[file,~] = uigetfile(['*.mat'],'Load File','MultiSelect', 'off');
if isequal(file,0)
disp('Nothing Selected')
else
try
app.Data = load(file);
Timestep= app.Data.Profile(1,:);
Power = app.Data.Profile(2,:);
plot(app.UIAxes,Timestep,Power)
app.PROFILENAMEEditField.Value = file;% Set the file name here
catch
errordlg(['There was a problem loading the .mat',' file'],'Load Error!');
return;
disp(['User selected ',file]);
end
end
%% function for the EditField

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Files and Folders에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by