Not enough Input Argument error
2 views (last 30 days)
Show older comments
% 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
3 Comments
Answers (1)
Cris LaPierre
on 16 Sep 2021
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 Comments
Cris LaPierre
on 18 Sep 2021
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
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!