How to solve this issue?Help me out?
Show older comments
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 Comments
Nath
on 8 Mar 2013
classdef CEntity
properties
RandNumb
end
methods
function obj = CEntity
obj.RandNumb= InitArray12()
end
end
end
function v=InitArray12()
v=randi(100)
end
Cedric
on 8 Mar 2013
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
Accepted Answer
More Answers (0)
Categories
Find more on Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!