How to solve: Error using "csvread". Too many output arguments
6 ビュー (過去 30 日間)
古いコメントを表示
I want to read 40 .csv files. In every csv file there are 251 rows and 4 columns. it is showing error:
Error using csvread
Too many output arguments.
Error in readingALLcsvFILES (line 8)
[num,txt,raw{k}] = csvread(myfilename); %reading the execel file
This is my code:
clear all
numfiles = input('Enter no. of files'); %entering no. of files to be calculated
mydata = cell(1, numfiles); %creating a cell array for all the files
for k = 1:numfiles %begin of loop for each file calculation
myfilename = sprintf('DAT0000%d.csv', k-1); %calling the excel file
[num,txt,raw{k}] = csvread(myfilename); %reading the execel file
n{k}=raw{k}(1,1); % Giving weld time in a cell array of 1x1
n{k}=cell2mat(n{k}); % converting n into a matrix value
DCRfile{k} = raw{k}(2:(n{k}+1),:); % creating a cell array for DCR with time, cuurent and voltage value
DCRfile{k}(:,2)=[]; % deleting 2nd column with value '*'
DCRfile{k}=string(DCRfile{k}); % convering DCR cell array to ta string array
DCRfile{k}(:,1)=erase(DCRfile{k}(:,1),'ms'); % erasing units in DCR string array
DCRfile{k}(:,2)=erase(DCRfile{k}(:,2),'kA');
DCRfile{k}(:,3)=erase(DCRfile{k}(:,3),'V');
DCRfile{k}=double(DCRfile{k}); % converting string array to a numeric array
%Calculation of DCR
for i = 1:n{k}
DCR{k}(i) = (DCRfile{k}(i,3))/(DCRfile{k}(i,2))*1000;
end
%Calculation of R(min) and Time at R(min)
[Rmin{k},Tmin{k}] = min(DCR{k});
%Calculation of Beta Peak
Rmax{k} = 0;
for i = Tmin{k}:n{k}
% DCRx(i-Tmin+1)=DCR(i);
if Rmax{k} < DCR{k}(i)
Rmax{k} = DCR{k}(i);
end
end
Beta{k} = Rmax{k};
Tmax{k} = find(DCR{k}==Beta{k}); %Time at Beta Peak
%Mean DCR
DCRmean{k}=sum(DCR{k})/n{k};
%Calculation of Heat Input
for i = 1:n{k}
HI{k}(i) = DCRfile{k}(i,2)*DCRfile{k}(i,2)*DCR{k}(i)/1000;
end
THI{k}=sum(HI{k}); %Total Heat Input
end
8 件のコメント
madhan ravi
2019 年 1 月 30 日
Well it had already been answered in your previous question so take a moment to read the answers in your previous question!
回答 (2 件)
Jeremy Hughes
2019 年 1 月 30 日
If you have both text and numeric data, I suggest you try READTABLE instead.
0 件のコメント
M
2019 年 1 月 30 日
As the error says, you are requesting two many outputs arguments.
The function 'csvread' only returns one output.
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!