Calling an object's method that changes its property not doing what I want.
조회 수: 2 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Chirag Gupta
2011년 12월 16일
This would stem from the difference between Value classes and handle classes. Its explained here: http://www.mathworks.com/help/techdoc/matlab_oop/brfylwk-1.html
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Handle Classes에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!