Hi, I am new to Matlab classes. I want to change the value of some properties in a function called ChangeProperties from within the class. But I can't do it. What am I doing wrong?
classdef agent_type properties v id end methods function p=agent_type(i) p.id=i; p.v=10*randn(1,2); end function y=ChangeProperties(this,step) [this.v(step,:)]=zeros(1,2); y=[this.v(step,:)]; end endend
when I run: agent.ChangeProperties(2) I get a random 1×2 vector. It should be a zero 1×2 vector. Why does this.v remain the same?
Thank you
Best Answer