Retrieve data from Hard Drive (Local Directory)

 채택된 답변

Richard
Richard 2012년 4월 12일

0 개 추천

I would think that you need to use the dir command. If the files are located in your C drive then:
clear all
TopFolder = 'C:\';
SubFolder = dir(TopFolder);
SubFolder = SubFolder(3:end); % the first two here are just pointers
a = struct2cell(SubFolder);
Name = a(1,:);
This will give you the name of the files where your data is located. You then need to obtain the name of each of the files in that folder:
b = cellfun(@(x)dir(fullfile(TopFolder,x)),Name,'un',0);
c = cellfun(@(x)x(3:end),b,'un',0);
d = cellfun(@(x)struct2cell(x),c,'un',0);
FileS = cellfun(@(x)x(1,:),d,'un',0);
You can then import the data using one of the built in matlab functions:
If your data is stored in a text file I would recommend using textscan.

추가 답변 (1개)

Valentino
Valentino 2012년 4월 12일

0 개 추천

Hi Lestyn,
I trust you are well and all is good. Thanks for the reply on my question posted. I just have one question further:
Say this is the location where my data is stored:
C:\work\data\2003\302
How will the code look? I'm a bit confused about the subfolder part and the obtaining part of each file in the folder.
What Matlab functions do I need to use to import data?

카테고리

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

태그

질문:

2012년 4월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by