Not enough Input Argument error
1 次查看(过去 30 天)
显示 更早的评论
% I am certain that the two 'Test' variables are not empty or invalid. I am trying to call a function CountyryData using 2 input variables!
app.Test = string(cellfun(@(Data) Data(1), app.Data(61,3)));
app.Test2=app.C(61,1);
app.CumulativeCases=CountryData(app.Test2,app.Test);
%Calling this Function - that requires 2 input variables. However the Not enough Arguments error keeps coming up..
classdef CountryData < Countries
properties
CCC
Temp
end
methods
function obj = CountryData(name1,data1)
obj.Temp=name1;
obj.CCC=data1;
end
end
end
回答(1 个)
Cris LaPierre
2021-9-16
CountryData is a class. I believe you need to create an instance of your object and then use that when calling your method. See this answer. See this documentation page.
Something like this.
c = CountryData;
CountryData(c,app.Test2,app.Test)
3 个评论
Cris LaPierre
2021-9-18
Your class is slightly different from the one I pointed you to. The main difference is that your function has the same name as your class (CountryData), making is a constructor method. From the page I pointed you to:
- The constructor method has the same name as the class and returns an initialized object of the class.
Your function has 3 inputs, so when you create your class instance, you must do so using 3 inputs.
app.Data = CountryData(input1, input2, input3)
Because it is a constructor method, you do not need to provide the object as an input.
Once you have created an instance of the course, you would use dot notation to access the individual properties. For example
app.Data.Country
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!