MATLAB Answers

Not enough Input Argument error

조회 수: 1(최근 30일)
PADMAKAR
PADMAKAR 2021년 9월 16일
댓글: Cris LaPierre 2021년 9월 18일
% 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
PADMAKAR
PADMAKAR 2021년 9월 18일
I have attached 2 classdeg files. Countries is a superclass and CountryData is a subClass.
I am just testing the CumulativeCases Object using some Test data randomly created.

댓글을 달려면 로그인하십시오.

답변(1개)

Cris LaPierre
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
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

댓글을 달려면 로그인하십시오.

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by