Mostrar comentarios más antiguos
EDU>> fid = csvread(uigetfile({'*.csv';'*.txt';'*.dat'}, 'Select the CV File'), 2, 1, 'eof');
??? Attempted to access range(3); index out of bounds because numel(range)=0.
Error in ==> dlmread at 108
if r > range(3) || c > range(4), result= []; return, end
Error in ==> csvread at 54
m=dlmread(filename, ',', r, c, rng);
The top is the line I am trying to execute and the bottom is the subsequent error message I am receiving. I have tried trouble shooting it myself but I am not sure what the problem is. Can anyone help?
Respuestas (5)
Richard Brown
el 23 de Abr. de 2012
0 votos
The fourth argument to csvread should be a range, i.e. a vector with four entries. You have 'eof'. Try removing this argument and see if this fixes your problem.
1 comentario
Lukas
el 23 de Abr. de 2012
Walter Roberson
el 23 de Abr. de 2012
0 votos
csvread() cannot be used for files that have text headers. Not even when you specify the row and column.
If you have text headers, use textscan() directly.
4 comentarios
Lukas
el 23 de Abr. de 2012
Walter Roberson
el 24 de Abr. de 2012
For the case of a file that is numeric except for header lines:
numheader = 1; %adjust to the actual number of headers
numcol = 7; %adjust to the actual number of columns
thisfmt = repmat('%f', 1, numcol);
fid = fopen('CV US Protocol_BD1726-54 1000ud1.csv', 'rt');
C = textscan(fid, thisfmt, 'Delimiter', ',', 'HeaderLines', numheader);
fclose(fid);
If this is not what your file looks like, then a sample of your file would help.
Lukas
el 27 de Abr. de 2012
Lukas
el 27 de Abr. de 2012
Lukas
el 24 de Abr. de 2012
Lukas
el 24 de Abr. de 2012
Image Analyst
el 27 de Abr. de 2012
csvread expects a bunch of numbers, not mixed numbers and text, and different numbers of things on each line, like you have:
AnalysisSetup, Analysis.Setup.Title, CV US Protocol
Dimension1, 201, 201, 201
Dimension2, 4, 4, 4
DataName, VBias, C, G
DataValue, -10, 7.14698E-11, 7.31843E-06
Since each line is so vastly different, you might have to read each line with fgetl() or fgets() and parse each line depending on what it looks like.
3 comentarios
Lukas
el 27 de Abr. de 2012
Image Analyst
el 27 de Abr. de 2012
You can do that if you want. Read each line in one at a time like I said, parse it into things between the commas (you can use allwords for that http://www.mathworks.com/matlabcentral/fileexchange/27184-allwords) and then put those sentence fragments into cells.
Lukas
el 4 de Mayo de 2012
Categorías
Más información sobre Text Data Preparation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!