MATLAB Answers

1

Get a property from a class

Asked by Andrea Agostini on 22 Jul 2019
Latest activity Commented on by Andrea Agostini on 23 Jul 2019
Hello,
I have a class as per attached file "ktmDbiAccess.m".
I would like the property "fullFileName" is read ony; in my understanding I have to greate a get method to do that but I cannot understand how. I have found this example but it is not clear me yet how I have to modify the class and how should I call the "get" method in the caller script.
May you please provide an example? Or just modify my class.
regards,
Andrea

  0 Comments

Sign in to comment.

Products


Release

R2018b

2 Answers

Answer by Sean de Wolski
on 22 Jul 2019
 Accepted Answer

You can set the SetAccess attribute of the properties block including it to make it read-only. No reason to deal with get(), actually, it would be set(), but still unnecessary.
properties (SetAccess = private)
fullFileName
end

  1 Comment

thanks; it works

Sign in to comment.


Matt J
Answer by Matt J
on 22 Jul 2019
Edited by Matt J
on 22 Jul 2019

All you have to do is change the SetAccess property attribute, e.g.,
properties (SetAccess=private)
fullFileName
end

  1 Comment

thanks; it works

Sign in to comment.