How can I solve the error: error using csvread Too many output arguments?

I am trying to do some calculations with the data extracted from some csv files. It return the error: Error using csvread. Too many output arguments.
Error in myDataProcessV2 (line 13)
[VgAll,IdAll]=csvread(Data_File(j).name,'B251:B602','E251:E602');
What is the correct way to do it?
SrcDIR=uigetdir('Choose the source folder!');
cd(SrcDIR);
Data_File=dir('*.csv');
counts=size(Data_File);
onOffRatioCollection=zeros(counts(1),1);
SSCollection=zeros(counts(1),1);
mobilityCollection=zeros(counts(1),1);
VonCollection=zeros(counts(1),1);
hysCollection=zeros(counts(1),0);
for j=1:counts(1)
[VgAll,IdAll]=csvread(Data_File(j).name,'B251:B602','E251:E602');
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

回答 (1 件)

Star Strider
Star Strider 2019 年 1 月 13 日

0 投票

The csvread function has only one output.
Perhaps you were thinking of the xlsread (link) function?

4 件のコメント

Zhiyu Zhao
Zhiyu Zhao 2019 年 1 月 14 日
It gives the same error when I use xlsread.
Walter Roberson
Walter Roberson 2019 年 1 月 14 日
You can only provide one range at a time for csvread or xlsread .
In particular you cannot read into two different variables by providing two different ranges. You will need to either make two different calls or else make a single call for reading in B251:E602 and throwing away the entries you do not need.
Alternately you could use detectImportOptions() and modify the results to select the variables you want to read, and then use readtable() passing in the filename and the modified options.
Zhiyu Zhao
Zhiyu Zhao 2019 年 1 月 15 日
Thank you very much!
Star Strider
Star Strider 2019 年 1 月 15 日
Our pleasure!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeVariables についてさらに検索

質問済み:

2019 年 1 月 13 日

コメント済み:

2019 年 1 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by