Not enough Input Argument error
Mostrar comentarios más antiguos
% 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 comentarios
Geoff Hayes
el 16 de Sept. de 2021
Padmakar - perhaps the issue is with the Countries class? Please copy and paste the full error messag eto this question as that might reveal where the error is. Also, what are the values for app.Test2 and app.Test?
PADMAKAR
el 18 de Sept. de 2021
PADMAKAR
el 18 de Sept. de 2021
Respuestas (1)
Cris LaPierre
el 16 de Sept. de 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 comentarios
PADMAKAR
el 18 de Sept. de 2021
PADMAKAR
el 18 de Sept. de 2021
Cris LaPierre
el 18 de Sept. de 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
Categorías
Más información sobre Construct and Work with Object Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!