I've a function that is called multiple times
function fun()
persistent x y z
if isempty(x)
x = %
end
if isempty(y)
y = %
end
if isempty(z)
z = %
end
end
How can I do better without having multiple if statements? Can we vectorize the variables and check once?
Any suggestions will be really helpful

 채택된 답변

Rik
Rik 2020년 5월 5일

1 개 추천

You can use use this:
function fun()
persistent x y z
if isempty(x)
x = %
y = %
z = %
end
%rest of your function
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

질문:

2020년 5월 5일

답변:

Rik
2020년 5월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by