Retrieve data from Hard Drive (Local Directory)
3 次查看(过去 30 天)
显示 更早的评论
How can I build my own m file to retrieve the data from my hard drive.
0 个评论
采纳的回答
Richard
2012-4-12
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.
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Standard File Formats 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!