How do I Import multiple data files?

Hi All
Hope you can help me with this! I am hopelessly struggling at trying to open 7 data files which have data arranged into rows rather than columns.
I also want to skip the first 4 lines in each txt file as they contain no data.
I have done the recommended steps- using the import data and creating a function.
then doing the following code in my main file:
numFiles = 7;
startRow = 5;
endRow = inf;
myData = cell(1,numFiles);
for fileNum = 1:numFiles
fileName = sprintf('Record_%d.txt',fileNum);
myData{fileNum} =importfile(filename, startRow, endRow)
end
Unfortunately I keep getting the error: unidentified variable 'filename' I am not sure where I am going wrong Do I need to name the function I am using somewhere?
Thanks

댓글 수: 1

You are using
fileName
on one line and
filename
on the next. I haven't looked in detail at the rest of your code, but that is likely the reason for the error you state. Matlab is case sensitive.

댓글을 달려면 로그인하십시오.

답변 (2개)

Stephen23
Stephen23 2018년 2월 9일

0 개 추천

MATLAB is case sensitive: you define this variable:
fileName = sprintf(...)
but then try to call a different variable:
importfile(filename,...)
Note the N vs. n.
Moris Bouja
Moris Bouja 2018년 5월 23일

0 개 추천

Hi Serena , can you help me what should i do to import many data files into matlab? i am new i have no idea

카테고리

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

질문:

2018년 2월 9일

댓글:

2018년 5월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by