フィルターのクリア

Problem with the level 2 M file S function

1 回表示 (過去 30 日間)
Bhumin Desai
Bhumin Desai 2012 年 7 月 12 日
I wrote the lvl 2 M file which consists of the If Elseif loop. and my i/p to the S function block is two sine wave blocks. Below is the logic which I used...
function Update(block)
vsd = block.InputPort(1).Data;
vsq = block.InputPort(2).Data;
%k = block.Dwork(1).Data;
%x = block.Dwork(2).Data;
if vsd>0 & vsq>=0 & vsd>vsq;
k=1;
elseif vsd>0 & vsq>=0 & vsd<=vsq;
k=2;
elseif vsd<=0 & vsq>0;
k=3;
elseif vsd<0 & vsq<=0 & vsd<vsq;
k=4;
elseif vsd<0 & vsq<0 & vsd>=vsq;
k=5;
elseif vsd>=0 & vsq<0;
k=6;
end
block.Dwork(1).Data = k;
%end function
Now the question is it gives me the desired o/p only for the smaller simulation times, as I increased the simulation times, I didn't get the o/p which I want. It's like this If Elseif loop is true only for the first one or two cycles of the sine waves only.
So can anyone help me??
  1 件のコメント
Kaustubha Govind
Kaustubha Govind 2012 年 7 月 12 日
Perhaps you should set breakpoints in your code to debug the issue? It's hard for us to tell without looking at your input signal.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by