Borrar filtros
Borrar filtros

Problem with the level 2 M file S function

1 visualización (últimos 30 días)
Bhumin Desai
Bhumin Desai el 12 de Jul. de 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 comentario
Kaustubha Govind
Kaustubha Govind el 12 de Jul. de 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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by