Newbie: How can I import and read data files (text files) automatically?
2 次查看(过去 30 天)
显示 更早的评论
I would like to import data into a m file. Data has extension ".epi". I figured out how to import it (see code following) but would like to automatically get prompted and choose it from the explorer when running the m file. Thanks heaps, I'm a real beginner!
function importAEPdata(AEPfile)
%IMPORTAEPDATA(AEPdata)
% Imports data from the specified file
% AEPfile: file to read
% Import the file
AEPdata = importdata(AEPfile);
% Create new variables in the base workspace from those fields.
vars = fieldnames(AEPdata);
for i = 1:length(vars)
assignin('base', vars{i}, AEPdata.(vars{i}));
end
0 个评论
采纳的回答
Walter Roberson
2013-6-3
If you want the user to select a single file name, use uigetfile()
If you want a directory of names to be processed, see http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Low-Level File I/O 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!