Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: importdata Standalone application
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Rouzbeh

Posts: 9
Registered: 9/7/12
importdata Standalone application
Posted: Sep 7, 2012 12:04 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello,

I am working on creating a signal/data processing application that read a series of files performs some analysis and returns the results. As part of this process I have a function that imports a series of text files containing the data I need. (combination of strings: headings, date and time, and numerical values). I am trying to create a standalone application that performs this operation (data importing for now). The function takes an input argument in the form of a path name to the folder that includes the data files, saves the names of the files and then imports the data into a structure. When I run the stand alone application I get the following error:

Error using importdata <line 137>
Unable to open file.

Error in data_load <line ...> <mdata_st(:,j) = importdata(fnames(i).name,'\t');>

MATLAB:importdata:FileNotFound

I would appreciate it if anyone could give me some pointers on how to work around this problem. Please note that since the file format is not known before use I (to the best of my knowledge) can not use textscan.

Below is the code for the function I described above.

I also use a batch file to run the code; and I have tested the application without the last loop in the function and it works fine.

Thank you very much,

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [fnames,len,filechar,names] = data_load(directorypath)

% open a dialogue box; ask user to select folder with data files
directname = uigetdir(directorypath, 'Pick Folder Containing Data');
fnames = dir(directname); % read files in the user selected folder
len = length(fnames); % get the number of files in the folder

% set loop counter variables
k = 3;
r = 1;
while k <=len
names(r,:) = cellstr(regexprep(fnames(k,1).name, '.txt', ''));
k = k+1;
r = r+1;
end

filechar = char(names);

dim = size(fnames);
j = 1;
i = 3;

%%%%%%%%%%%%%%%%%%%%%%%%%
% this loop reads data contained in each data file in order of name until
% all files are read
while i <=dim(1)
mdata_st(:,j) = importdata(fnames(i).name,'\t');
i = i+1;
j = j+1;
end



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.