Access different property from set method in class
Mostrar comentarios más antiguos
Hello all,
I have a class that has a user-controlled property to turn on/off the use of gpuArrays. I want to access this property in a "set" method for a different property. That way, I can immediately store the new property in GPU memory upon calling the set method. However, I see the warning: "A set method for a non-Dependent property should not access another property ('useGpu')". Is there a smarter way to have access to the useGpu property? The use of a global variable seems sloppy to me.
My set method looks as follows:
function obj = set.smaps(obj,val)
val = single(val);
if obj.useGpu
obj.smaps = gpuArray(val);
end
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!