Use drop down menu to select file to plot
古いコメントを表示
Hi,
I have multiple .mat files in my folder that I load into matlab using dirfiles. How can I have a drop down menu or list that lets me select which file I want to plot and switch from one file to the other one?
for k = 1:numfiles
myfilename = dirfiles(k).name;
fullFileName = fullfile(PathName, myfilename);
mydata{k} = load(fullFileName);
end
5 件のコメント
See
doc uigetfile
to have user selection from git-go or populate a list box for the selection if know the root names to provide from--
doc listdlg
Konvictus177
2021 年 10 月 17 日
編集済み: Konvictus177
2021 年 10 月 17 日
dpb
2021 年 10 月 17 日
One of my apps uses a menu to select/change a workbook desired sheet -- the callback for the given menu action function looks like
% Menu selected function: BillingSheetMenu
function BillingSheetMenuSelected(app, event)
if ~exist(app.billQualFile,'file')
errordlg([app.billQualFile "Not Found. Must Set Billing File First."])
return
end
sheets=sheetnames(app.billQualFile);
iv=find(contains(sheets,app.billSheet,'IgnoreCase',false));
if isempty(iv), iv=1; end
ix=listdlg('PromptString','Select Billing Sheet','ListString',sheets,'selectionmode','single','initialvalue',iv);
if isempty(ix), ix=iv; end
app.billSheet=sheets(ix);
app.BillingSheetTextArea.Value=app.billSheet;
end
You'll have to have a callback function tied to something that would mimic something like the above with the content of the listbox being the files list.
The same app menu to select the file function uses uigetfile instead --
% Menu selected function: BillingFileMenu
function BillFileFunction(app, event)
filestr=fullfile(app.billPath,'*Bill*.xlsx');
[app.billFile,app.billPath]=uigetfile(filestr,'Select Desired Billing File',"MultiSelect","off");
try
app.BillingFolderTextArea.Value=app.billPath;
app.BillingFfileTextArea.Value=app.billFile;
app.billQualFile=fullfile(app.billPath,app.billFile);
%app.BillingSheetTextArea.Value=app.billSheet;
catch
% leave unchanged; if nothing there, catch it when trying to run update
end
Walter Roberson
2021 年 10 月 17 日
filenames = {dirfiles.name};
[indx, tf] = listdlg('ListString', filenames, 'PromptString', 'Select a file');
if ~tf; return; end %user cancel
fullFileName = fullfile(PathName, filenames{indx});
mydata = load(fullFileName);
Konvictus177
2021 年 10 月 18 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で App Building についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!