Is there a way to detect the index/position of the setted value inside a new defined setter method?
I mean, if I call
that
function set.Prop(obj,val)
if
val = ...
end
obj.Prop = val;
end
does different calculations on specific indices.
THX
In MATLAB documentation is a short description I don't really understand________________________________________
Access Methods and Properties Containing Arrays
You can use array indexing with properties that contain arrays without interfering with property set and get methods.
For indexed reference:
val = obj.PropName(n);
MATLAB calls the get method to get the referenced value.
For indexed assignment:
obj.PropName(n) = val;
MATLAB:
- Invokes the get method to get the property value
- Performs the indexed assignment on the returned property
- Passes the new property value to the set method
2 Comments
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/566571-can-i-detect-array-index-inside-setter-method#comment_941703
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/566571-can-i-detect-array-index-inside-setter-method#comment_941703
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/566571-can-i-detect-array-index-inside-setter-method#comment_941763
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/566571-can-i-detect-array-index-inside-setter-method#comment_941763
Sign in to comment.