How to define a persistent array in an Embedded function

조회 수: 14 (최근 30일)
honglin
honglin 2012년 10월 29일
I want to define some persistent arrays in an embedded function,and change their walues in cycles,but I don't know how to define this. I had trid this:
persistent X;
if isempty(X)
X=0;
end
but obviously,it's wrong. Please help me,thanks
  댓글 수: 3
honglin
honglin 2012년 10월 30일
Thanks,it's userful for me.
Kaustubha Govind
Kaustubha Govind 2012년 10월 31일
Glad it helped! I added an answer with that code - could you please accept it if is resolves the question?

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

답변 (1개)

Kaustubha Govind
Kaustubha Govind 2012년 10월 31일
How about:
persistent X;
if isempty(X)
X=zeros(1,5);
end

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by