How to define a persistent array in an Embedded function

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 件のコメント

Kaustubha Govind
Kaustubha Govind 2012 年 10 月 29 日
How about:
persistent X;
if isempty(X)
X=zeros(1,5);
end
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 日

3 投票

How about:
persistent X;
if isempty(X)
X=zeros(1,5);
end

カテゴリ

ヘルプ センター および File ExchangeSimulink Functions についてさらに検索

質問済み:

2012 年 10 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by