Problem with the level 2 M file S function

1 vue (au cours des 30 derniers jours)
Bhumin Desai
Bhumin Desai le 12 Juil 2012
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 commentaire
Kaustubha Govind
Kaustubha Govind le 12 Juil 2012
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.

Connectez-vous pour commenter.

Réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by