MATLAB Answers

Importing data from different directories

조회 수: 73(최근 30일)
Hi,
I have data saved in several different directories and many often I need to run the same matlab script to make some post-processing. Now my question:
How can I run my script and select the data to import as they belong to different directories?
I have been using uigetfile() but to select files from the current directory only.
Thank you. C. C.

채택된 답변

Walter Roberson
Walter Roberson 28 Mar 2011
[filename, pathname] = uigetfile(...);
completename = fullfile(pathname, filename);
Then use completename as the name to open or load.

추가 답변(3개)

Ian
Ian 28 Mar 2011
You could try this FE submission:
This is a GUI application that allows multiple files or directories to be selected and allows you to manage the list (remove files, reorder, etc.) before returning. It has basic filtering as well as regular expression filtering and navigation of the file system is easy. The output is configurable (cell, struct or char arrays). It is written entirely in M and so is platform independent.

Chiara Modenese
Chiara Modenese 28 Mar 2011
Thanks Ian, I will have a look at that as it seems what I need but am having problems to download the files now, let's see if I can fix it.
As for your answer, Walter, for me it does not work in case of MULTIPLE file selection (see error message below), which is actually my need. Any further hint?
The code:
[FileName,PathName,FilterIndex] = uigetfile('*.txt','MultiSelect','on');
CompleteName = fullfile(PathName, FileName);
The message:
??? Undefined function or method 'eq' for input arguments of type 'cell'.
Error in ==> fullfile at 37
if (f(end)==fs) && (part(1)==fs),
Error in ==> try_headers at 17
CompleteName = fullfile(PathName, FileName);
Cheers, C.
  댓글 수: 2
Chiara Modenese
Chiara Modenese 29 Mar 2011
Thanks a lot!
I have also found the way to follow Walter's suggestion, by using cells if multiple files are selected. Thanks to all, anyway.
Bye, Chiara

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


Chiara Modenese
Chiara Modenese 29 Mar 2011
It seems that my problem would not be solved in the sense that I am not able to select files from different directories, I mean, to select multiple files from multiple directories. I would like to code something simple in my script that could handle that and maybe not make use of other people code, possibly. Had you any other suggestions, I would appreciate it.
Chiara
  댓글 수: 2
Walter Roberson
Walter Roberson 30 Mar 2011
Right, uigetfile() only supports selecting from one directory at a time.

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by