hi why my while loop is never end? it running continuously.
Mostrar comentarios más antiguos
function y = fcn
%#codegen
y=0;
i=0;
coder.extrinsic ('fprintf');
while(i<10)
if(y==1)
y=0;
fprintf('on\n');
else
y=1;
fprintf('off\n');
end
i = i+ 1;
fprintf('i=%d\n',i);
end
12 comentarios
Alex Mcaulley
el 26 de Mzo. de 2019
It is ok. It stops when i == 10
KAMALAKANNAN R
el 26 de Mzo. de 2019
Alex Mcaulley
el 26 de Mzo. de 2019
try with a for loop instead
KAMALAKANNAN R
el 26 de Mzo. de 2019
KAMALAKANNAN R
el 26 de Mzo. de 2019
Geoff Hayes
el 26 de Mzo. de 2019
How is fcn being called? Perhaps it is being called continuously and so creates the illusion that the while loop never ends.
KAMALAKANNAN R
el 28 de Mzo. de 2019
Geoff Hayes
el 28 de Mzo. de 2019
How is fcn being called?
KAMALAKANNAN R
el 29 de Mzo. de 2019
Walter Roberson
el 29 de Mzo. de 2019
Is it showing i= with numbers greater than 10? Or is it cycling showing 1 to 10 over and over again?
Your function would be invoked once per time step, so if you are running more than one time step it is going to repeat multiple times.
KAMALAKANNAN R
el 29 de Mzo. de 2019
Walter Roberson
el 29 de Mzo. de 2019
It should already be invoked once per time step if you are using discrete time. If you are using continuous time then I am not sure how often it would get invoked.
The problem I see is that you are running for multiple time steps rather than just having the function invoked at initialisation time.
Respuestas (0)
Categorías
Más información sobre Model Verification en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
