Not enough Input Arguments

조회 수: 11 (최근 30일)
Sarthak Anand
Sarthak Anand 2022년 12월 10일
댓글: Sarthak Anand 2022년 12월 10일
I was executing the code but there is an error showing:
Not enough input arguments.
Error in importStormData (line 44)
data = readtable(filename, opts)
The syntax is correct and the intialization of the opts variable has been done as follows:
opts = delimitedTextImportOptions("NumVariables", 23);
opts.DataLines = dataLines;
opts.Delimiter = ",";
opts.VariableNames = ["Var1", "Var2", "State", "Var4", "Month", "Event_Type", "Begin_Date_Time", "Timezone", "End_Date_Time", "Injuries_Direct", "Injuries_Indirect", "Deaths_Direct", "Deaths_Indirect", "Var14", "Property_Cost", "Var16", "Crop_Cost", "Begin_Lat", "Begin_Lon", "End_Lat", "End_Lon", "Episode_Narrative", "Event_Narrative"];
opts.SelectedVariableNames = ["Month", "Event_Type", "Begin_Date_Time", "Timezone", "Injuries_Direct", "Injuries_Indirect", "Deaths_Direct", "Deaths_Indirect", "Property_Cost", "Crop_Cost", "Begin_Lat", "Begin_Lon", "End_Lat", "End_Lon", "Episode_Narrative", "Event_Narrative"];
opts.VariableTypes = ["string", "string", "categorical", "string", "categorical", "categorical", "datetime", "categorical", "datetime", "double", "double", "double", "double", "string", "double", "string", "double", "double", "double", "double", "double", "categorical", "string"];
opts = setvaropts(opts, 7, "InputFormat", "yyyy-MM-dd HH:mm:ss");
opts = setvaropts(opts, 9, "InputFormat", "yyyy-MM-dd HH:mm:ss");
opts = setvaropts(opts, [1, 2, 4, 14, 16, 23], "WhitespaceRule", "preserve");
opts = setvaropts(opts, [1, 2, 3, 4, 5, 6, 8, 14, 16, 22, 23], "EmptyFieldRule", "auto");
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
  댓글 수: 1
Image Analyst
Image Analyst 2022년 12월 10일
Did you assign filename? What happens if you just omit the opts from the call to readtable?
If you have any more questions, then attach your data file with the paperclip icon after you read this:

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2022년 12월 10일
importStormData is a function that expects at least one parameter, which it refers to as filename . However when you ran the code, you did not provide a file name in the corresponding parameter slot.
The error is not saying that you did not provide enough input arguments to readtable, the error is saying that you did not provide enough input arguments to importStormData
  댓글 수: 1
Sarthak Anand
Sarthak Anand 2022년 12월 10일
Yes. I understand it now. Comitted an elementary rookie mistake and was fretting over it for a long time. Thanks for your support.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by