Class : Error while assigning variables in constructor
조회 수: 2 (최근 30일)
이전 댓글 표시
I am getting error while assigning variables in classes :
properties
% The antenna object from the phased array toolbox
ant = [];
% Frequency in Hz
fc = 0;
end
methods
function myobj = ElemWithAxes(fc, ant)
% Constructor
% Inputs: fc is the carrier frequency in Hz and ant is
% an antenna compatible with the phased array toolbox. It must
% support the ant.pattern() method.
% TODO: Assign fc and ant to the class variables
myobj.fc = fc;
myobj.ant = ant;
end
I get the following :
Not enough input arguments.
Error in ElemWithAxes (line 40)
myobj.fc = fc;
Where does the problem lie ?
댓글 수: 0
답변 (1개)
per isakson
2022년 2월 25일
편집: per isakson
2022년 2월 25일
How did you call the constructor?
I added a few line to make your code a syntactically correct class. And tested the constructor.
ewa = ElemWithAxes(1,2)
ewa = ElemWithAxes()
Did you call the constructor without input argument values?
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Software Development Tools에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!