Listdlg: Only display .wav files and how get filename from s?

5 visualizzazioni (ultimi 30 giorni)
Hey all,
With the following code taken (and adapted) from a search on here, I want to only display .wav files in the list. How is this possible?
Also, although i can check which file is chosen by its index in the list (using s), how do i get the string (filename and path etc) of the chosen list member?
d = dir;
str = {};
[s,v] = listdlg('PromptString','Select a wav file:',...
'ListSize', [160 160],...
'Name', 'Choose Audio File..',...

Risposta accettata

Star Strider
Star Strider il 17 Nov 2015
You only need to make a few changes in your code to get it to do what you describe:
d = dir('*.wav'); % Select Only ‘.wav’ Files
str = {};
[s,v] = listdlg('PromptString','Select a wav file:',...
'ListSize', [160 160],...
'Name', 'Choose Audio File..',...
if v
wav_name = str{s}; % File Name Of Selected File
wav_path = which(wav_name); % Path Of Selected File
fprintf(1, '\tNo file was selected.\n')
  4 Commenti
Edmund Paul Malinowski
Edmund Paul Malinowski il 19 Nov 2015
Hey Star, Hope you're ok. Sorry to bother you again but as I now have a GUI with a popup menu, whats the best way to populate the popup with the wav files using your code?
Star Strider
Star Strider il 19 Nov 2015
I’m fine. Thank you.
No bother, other than while I use inputdlg, listdlg and the simpler ones frequently, I don’t have enough experience with GUIs in general to be able to reply, especially not without seeing your code.
I suggest you start a new Question, and please include the relevant parts of your code so that we can see what you’re doing and test our solutions with it.

Accedi per commentare.

Più risposte (0)


Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by