Not enough Input Arguments

11 Ansichten (letzte 30 Tage)
Sarthak Anand
Sarthak Anand am 10 Dez. 2022
Kommentiert: Sarthak Anand am 10 Dez. 2022
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 Kommentar
Image Analyst
Image Analyst am 10 Dez. 2022
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:

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 10 Dez. 2022
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 Kommentar
Sarthak Anand
Sarthak Anand am 10 Dez. 2022
Yes. I understand it now. Comitted an elementary rookie mistake and was fretting over it for a long time. Thanks for your support.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by