MATLAB Answers

0

How to disable the set method of a class

Asked by Collin Smith on 12 Feb 2018
Hello,
Is it possible to temporarily disable a set method defined within a class?
For example, say I am communicating with an external instrument. To make this easier, I would like to have a class that handles all the communication code for me. This is an example of the class:
classdef InstrumentCommunicatorinator
properties
sample_length = 1e6;
end
methods
function obj = set.sample_length(obj,value)
obj.sample_length = value;
% Lines of code to set sample_length value on external instrument
end
end
end
This works well. Now when I set
InstrumentCommunicatorinator.sample_length = 100;
both my class and my instrument will by in sync, and have a sample length of 100.
However, say I want to make a bunch of settings by hand on the instrument, and transfer these settings FROM the instrument TO the InstrumentCommunicatorinator class. This is a case of when I want to assign values but NOT use the set function I defined. Is it possible to temporarily disable the set method in a class? Or is there a better way of doing this?
Thanks for the help!

  0 Comments

Sign in to comment.

Tags

0 Answers