Listdlg: Only display .wav files and how get filename from s?
조회 수: 2 (최근 30일)
이전 댓글 표시
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 = {d.name};
[s,v] = listdlg('PromptString','Select a wav file:',...
'SelectionMode','single',...
'ListSize', [160 160],...
'Name', 'Choose Audio File..',...
'ListString',str)
Thanks,
Paul..
댓글 수: 0
채택된 답변
Star Strider
2015년 11월 17일
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 = {d.name};
[s,v] = listdlg('PromptString','Select a wav file:',...
'SelectionMode','single',...
'ListSize', [160 160],...
'Name', 'Choose Audio File..',...
'ListString',str)
if v
wav_name = str{s}; % File Name Of Selected File
wav_path = which(wav_name); % Path Of Selected File
else
fprintf(1, '\tNo file was selected.\n')
end
댓글 수: 4
Star Strider
2015년 11월 19일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!