Hello, I am having problems using dlm read within a for loop. I would like to define a directory my files are in, the basic name of my files, a sequence of numbers at the end of my filename, and the file extension. An example of the filenames is as follows.
folder1/folder2/folder3/filename_000.txt
folder1/folder2/folder3/filename_001.txt
folder1/folder2/folder3/filename_002.txt
This continues up to n files. I would then like to read each file and take out specific data, hence the dlmread function.
What I have is as follows:
file_directory = 'folder1/folder2/folder3/'; file_prefix = 'filename_'; %My numbers 000, 001, 002, 003, etc. are all contained within an array called: A
file_suffix = '.txt'; for i=1:n %n for the number of files I want to load
filename = [file_directory file_prefix A(i) file_suffix]; temp=dlmread(filename ,'', [17 0 3664 1]); end
The code runs until temp=dlmread… wherein it gets an error of, "Filename must be a character vector."
Any way on how to fix this?
Best Answer