How to solve this issue?Help me out?
조회 수: 4 (최근 30일)
이전 댓글 표시
classdef CEntity
properties
RandNumb
end
methods
function obj = CEntity
InitArray12()
end
end
end
function InitArray12()
obj.RandNumb=randi(100)
end
How to send value which is calculated in the "InitArray12" function to "RandNumb" which is there in the properties
댓글 수: 3
Cedric
2013년 3월 8일
Are you sure that you want InitArray outside of your class definition? If so, Nath answered above; otherwise, you'll want to do something like:
classdef CEntity
properties
RandNumb
end
methods
function obj = CEntity()
obj = obj.InitArray12() ;
end
function obj = InitArray12(obj)
obj.RandNumb = randi(100) ;
end
end
end
채택된 답변
per isakson
2013년 3월 8일
Or this way
>> ce = CEntity()
ce =
CEntity
Properties:
RandNumb: 92
Methods
>>
where
classdef CEntity < handle
properties
RandNumb
end
methods
function obj = CEntity
InitArray12();
end
function InitArray12( obj )
obj.RandNumb = randi( 100 );
end
end
end
Read the entry "Value or Handle Class — Which to Use" in the on-line help
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Signal Reception and Recovery에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!