필터 지우기
필터 지우기

How to define and call non constructor object methods?

조회 수: 1 (최근 30일)
Francesco
Francesco 2013년 5월 18일
I have started using object in Matlab but I do not understand how to define or call non-constructor methods. Just a stupid example: defining this method :
if true
function NoteDot = CheckingTheDot(obj)
if obj.IsItAFullHeadNote
NoteDot = true;
end
end
end
and calling as S.CheckingTheDot() it works(S is an instance of the class of course). Instead if I define it as:
if true
function NoteDot = CheckingTheDot(obj,a)
if obj.IsItAFullHeadNote && a>2
NoteDot = true;
end
end
end
and calling it as S.CheckingTheDot(a); it returns the error: "Too many input arguments" Thanks in advance
  댓글 수: 1
Francesco
Francesco 2013년 5월 18일
sorry discard the "if true" and last end lines in the code

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

채택된 답변

per isakson
per isakson 2013년 5월 18일
편집: per isakson 2013년 5월 18일
Looks ok to me. Do
clear all, clear classes
and try the call
S.CheckingTheDot(a);
again. The old class definition might still be in memory. However, if so there should have been a warning.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Construct and Work with Object Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by