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
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
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!