Not enough Input Arguments

11 次查看(过去 30 天)
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