Calling an object's method that changes its property not doing what I want.
显示 更早的评论
Hello
An object has property MNL_beta and method train(input, output) that I want the object to update its MNL_beta property. What is actually happening is :
>> p1
p1 =
predictor_bundle
Properties:
MNL_beta: []
Methods
>> p1.train(input, output)
ans =
predictor_bundle
Properties:
MNL_beta: [3x1 double]
Methods
>> p1
p1 =
predictor_bundle
Properties:
MNL_beta: []
Methods
What has happened? The p1's value has not changed at all?!?
>> p1 = p1.train(input, output)
p1 =
predictor_bundle
Properties:
MNL_beta: [3x1 double]
Methods
>> p1
p1 =
predictor_bundle
Properties:
MNL_beta: [3x1 double]
Methods
But using the second syntax, it's done what I wanted. How do I accomplish the result of the second method, while using the syntax of the first method?
Thank you
采纳的回答
更多回答(1 个)
Evan
2011-12-16
2 个评论
Chirag Gupta
2011-12-16
classdef predictor_bundle < handle
....
end
Chirag Gupta
2011-12-16
http://www.mathworks.com/matlabcentral/answers/12056-matlab-oop-question
类别
在 帮助中心 和 File Exchange 中查找有关 Handle Classes 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!