How to asign the .m file selected from uigetfile() to the dropdown item permanently

2 vues (au cours des 30 derniers jours)
Harish M Y
Harish M Y le 3 Août 2021
I am creating an dynamic app where the user enters data to dropdown items and load all the corresponding files and folders to the working directory.
Initially the dropdown list was empty, When I press add button, I can enter the dropdown item name , the file and folder to be loaded to the current directory.
The newly added name will display in dropdown items. and the files/folders selected are loaded in the working direcory.
And the process continues like, the user can add n number of dropdown items and n number of files and folders to the directory.
My issue is when I add multiple dropdown items, the list will be displayed.
When I select any one dropdown item and press run button, the corresponding file loaded at the time of entering the name and loading folder to be run.
%% Global properties
properties (Access = public)
new % Description
%% Startup function
app.CalibrationModelDropDown.Items = dropdown;
%% Enter the new model and files/folders to the current working directory = app.EnterthemodelnameEditField.Value;
dropdown(:,end+1) = {};
app.CalibrationModelDropDown.Items = dropdown;
%% Load file/ folder to the newly added dropdwon item
[file,path] = uigetfile('*.m','Choose file to save') ;
copyfile([path file],pwd)
app.EditField.Value = sprintf(file);
x = uigetdir();
[filepath,name,ext] = fileparts(x);
copyfile(x,convertStringsToChars(pwd + "\" + string(name)))
app.EditField_2.Value = fullfile(filepath);
%% Run button -- is asking again which file to be selected to run, I want the assigned model for the respective dropdown item to be run when i press run
[filename, pathname] = uigetfile('*.m', 'Pick a .m file');

Réponses (0)


En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by