필터 지우기
필터 지우기

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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by