Class : Error while assigning variables in constructor
1 次查看(过去 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!