Reputation: 19
I want to read a bunch of files inside a loop function in MATLAB, but when I try the following code:
j = (i * 2000000);
A = dlmread('gr_at_0.l_%d', j);
I get the following error:
Error using sprintf
Invalid format.
Error in dlmread (line 71)
delimiter = sprintf(delimiter); % Interpret \t (if necessary)
Error in RDF (line 15)
A = dlmread('gr_at_0.l_%d', j);
the following file is one of the many files that I want to read:
'''gr_at_0.1_0'''
I would appreciate any comment.
Upvotes: 0
Views: 565
Reputation: 60615
You are using wrong syntax for dmlread
. Please read the documentation.
The second argument, for which you pass j
, an integer number, is the delimiter that the function will use to separate numbers in the file.
I think you intend to do:
fname = sprintf('gr_at_0.l_%d', j);
A = dlmread(fname);
Note that dmlread
is no longer recommended (i.e. deprecated), you should use readmatrix
since MATLAB R2019a.
Upvotes: 3