필터 지우기
필터 지우기

How to clear persistent variables from static method from another static method

조회 수: 3 (최근 30일)
Daniel Murphy
Daniel Murphy 2018년 10월 4일
댓글: Rik 2018년 10월 4일
Hi,
I'm having some difficulty clearing a persistent variable from inside a static method. My code is something like this:
classdef MyClass
properties
% code...
end
methods (Static)
function obj = firstStatic(a,b)
% trying to get this function to use a and b to overwrite the persistent obj in secondStatic
clear MyClass
obj = secondStatic(a,b)
end
function obj = secondStatic(a,b)
% this should collect the persistent obj that firstStatic populated
persistent perVar
if isempty(perVar)
perVar = % work out perVar from a and b
end
obj = perVar
end
end
However I'm not getting my new persistent object after a call to a and b. Is it possible to do this?
Thanks
  댓글 수: 1
Rik
Rik 2018년 10월 4일
You are looking for the functionality that global will provide. Aren't private class properties meant to solve this situation?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Construct and Work with Object Arrays에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by