Erorr using csvread dlm headerlines must be integer-valued

6 次查看(过去 30 天)
I get the following error when using csvread:
Error using dlmread (line 147)HeaderLines must be integer-valued. Error in csvread (line 48) m=dlmread(filename, ',', r, c); Error in myDataProcessV2_2 (line 13) [Vg]=csvread(Data_File(j).name,'B251:B360');
I don't know how to solve it. I'd appreciate any help.
for j=1:counts(1)
[Vg]=csvread(Data_File(j).name,'B251:B360');
[Id]=csvread(Data_File(j).name,'E251:E360');
IdSize=size(IdAll);,
IdSize(1)=IdSize(1)/2;
Id=IdAll(1:IdSize(1));
Vg=VgAll(1:IdSize(1));
if j == 1
lgIdCollection=zeros(IdSize(1),counts(1));
end
lgId=zeros(IdSize);
sqrtId=zeros(IdSize);
for i=1:IdSize(1)
lgId(i)=log10(Id(i));
sqrtId(i)=sqrt(Id(i));
end
lgIdCollection(1:IdSize,j)=lgId;
onOffRatioCollection(j)=seekOnOffRatio(Id);
SSCollection(j)=seekSS(lgId,Vg);
[VonLocation,VonCollection(j)]=seekVon(Id,Vg,lgId);
[kmax,Vth]=seekVth(Id,Vg,VonLocation,sqrtId);
hysCollection(j)=seekHys(IdAll,VgAll,VonLocation,176);
mobilityCollection(j)=seekMobility(kmax);
end

回答(2 个)

Nikilesh Chilkuru
Nikilesh Chilkuru 2019-1-18
I believe this error is actually arising because the columns you are reading from a csv file might be non-numeric. And the key thing to note is both 'dlmread' and 'csvread' can read only numeric data. It's mentioned in the doc link: csvread
The best way to read data when there are non-numeric fields involved is to use textscan. You can specify the format of the data you want to read with textscan. To get more information, refer: https://stackoverflow.com/questions/13115569/error-when-reading-data-from-csv-file-into-matlab
  1 个评论
Walter Roberson
Walter Roberson 2019-1-19
No, it is a plain positional parameter issue. Numeric R and C offsets have to appear before the character range expression.

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2019-1-19
csvread() does not accept Excel-style character ranges in either the second or third parameter, only in the 4th parameter.
[Vg]=csvread(Data_File(j).name, 250, 1, 'B251:B360');
The 1 column offset matches to 'B' and the 250 row offset matches to '251'. The numeric values in the second and third parameters are relative offsets, so you would use 0 for A (first column), 0 for first row, whereas the Excel ranges are absolute rather than relative. If you give the wrong numeric values compared to the range string then it will give a warning.

类别

Help CenterFile Exchange 中查找有关 Large Files and Big Data 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by