Erorr using csvread dlm headerlines must be integer-valued
조회 수: 12 (최근 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
댓글 수: 0
답변 (2개)
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
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
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!