필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Why do I need to use this.mag, why doesn't mag work?

조회 수: 1 (최근 30일)
Michael
Michael 2013년 7월 2일
마감: MATLAB Answer Bot 2021년 8월 20일
It seems that methods of classes always need to be passed the object i.e. the first parameter needs to be this, even if it is not used. The editor complains however if you pass it this and don't use it. Annoying.
Anyway my question is, why do you sometimes need to explicitly call a function/method with this in front of it and other times not.
e.g.
function y=mag(this,x)
y=max(abs(real(x)),abs(imag(x)))+floor(min(abs(real(x)),abs(imag(x)))/4);
end
this.mag(9)
works but
mag(9)
is not recognised as a function
Michael
  댓글 수: 1
Jan
Jan 2013년 7월 2일
@Michael: I've formatted your code to improve th readability.

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by