필터 지우기
필터 지우기

function with object as input

조회 수: 2 (최근 30일)
Nafila Farheen
Nafila Farheen 2019년 11월 5일
댓글: Walter Roberson 2019년 11월 6일
Hi, I am trying to write a function that will have the object as input . This is teh code body-
function Tx(obj)
obj.control.signal=zeros(4,1)
obj.cfg.freq=10khz
end
I want to know how to call the function?
  댓글 수: 4
Rik
Rik 2019년 11월 6일
If you want to modify the object, the function should probably return the modified object. Is this meant to be a method in a class?
You should be able to pass your object as an input variable, just like you would with any other function that requires an input.
Walter Roberson
Walter Roberson 2019년 11월 6일
Note that unless the object is derived from handle class that your code would only modify a temporary copy of the object which would be discarded after the function call. You need to either return the modified version (and store it) or use a handle class.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Handle Classes에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by