method accessing it's own object

조회 수: 3 (최근 30일)
Nathan Bblanc
Nathan Bblanc 2020년 9월 3일
댓글: Nathan Bblanc 2020년 9월 3일
it seems that a method inside a class definition cannot access it's own object, or at least it doesn't recognize it's own object. the only way i found around it was to put "obj" as one of the input parameter of the method, but this results in rather confusing lines like "Myobject.Mymethod(Myobject)". am I missing something?
many thanks
Nathan
  댓글 수: 1
Mohammad Sami
Mohammad Sami 2020년 9월 3일
Can you show your full code.

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

채택된 답변

Steven Lord
Steven Lord 2020년 9월 3일
If A is an instance of a class that has a method foo that accepts a class instance and a double scalar in that order, the following calling sequences are equivalent in the majority of cases.
foo(A, 5)
A.foo(5)
See the "Dot Notation vs. Function Notation" and "Case Where Result Is Different" sections on this documentation page for more information about most of the (usually less common) cases where they are not equivalent.
  댓글 수: 1
Nathan Bblanc
Nathan Bblanc 2020년 9월 3일
excellent, thank you for you answer

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by