Error in import data

header = 9;
delimiter = '\t';
for i = 1:2
filname = ['H1','2_I1sv00001 -',num2str(i),".txt"];
dat =importdata(filname,delimiter,header);
end
Error using importdata
Unable to open file.

 Accepted Answer

You didn't form the file names properly, so you were trying to read files that don't exist. You're also overwriting the results.
header = 9;
delimiter = '\t';
for i = 1:2
filname = sprintf('H1, 2_I1sv%05d.txt',i);
dat(i) =importdata(filname,delimiter,header);
end
dat
dat = 1×2 struct array with fields:
data textdata colheaders

1 Comment

AL
AL on 14 Mar 2023
Dear Rik,
Thank you so much. Have a wonderful week.

Sign in to comment.

More Answers (0)

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Products

Release

R2022b

Asked:

AL
on 14 Mar 2023

Commented:

AL
on 14 Mar 2023

Community Treasure Hunt

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

Start Hunting!