How to select multiple input file one at a time.

I have written a code in matlab with dialog box to open an input data file using diretorio = uigetdir; filename = uigetfile('*.txt','Select the INPUT DATA FILE');,
I do some process and produce the output using
prompt=('OUTPUT FILE NAME with .xls ext: '); title3='Output file name';
I have to run the same program for different input data files. Every time i run the program I feed the input file and get the ouput. Actually after the input data file is processed and the output file is created, the program should go to diretorio = uigetdir; for selecting another input file for processing / selection. Since there is no goto option in matlab, how to solve this. Can anyone help. Thanks in advance. Mohan.

 채택된 답변

dpb
dpb 2013년 9월 18일

9 개 추천

Several options depending on what you want/need...
a) if you're processing all the *.txt files in a subdirectory, there's no reason to have to select each manually -- use something like
d=dir('*.txt');
for ix=1:length(d)
fn=d(i).name
... do processing here, save results w/ dynamic output file name...
...
end
b) if you aren't doing all but know which ones, use uigetfile() but use the multipleselection optional input option --
fn=uigetfile('*.txt','Select the INPUT DATA FILE(s)','MultiSelect','on');
Then use a loop like above except the filenames are in the cell string array instead of a structure
Or,
c) if you really do need to select manually each time, just wrap your code in a while() loop and continue as long as there is a valid selection each time through...
flg=true; % set the logic variable to start the loop
while flg
fn=uigetfile('*.txt','Select the INPUT DATA FILE(s)','MultiSelect','on');
if isequal(filename,0), flg=0; break; end % no file selected; quit
% otherwise process as above here
...
end

댓글 수: 2

Great answer dude, thanks, that was very helpful!!
I have few readings (each reading is a batch of 6 sequences ) .
Further each sequence has 4 parameters (not so important at this point )
i have to seperate the two different sequences (in group of 4 and 2). Hoe should the filter be like for file selction?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

teimoor bahrami
teimoor bahrami 2019년 4월 23일

0 개 추천

hi what about .dat file extension how to select those files in subfolder

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

질문:

2013년 9월 18일

댓글:

2022년 1월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by