Borrar filtros
Borrar filtros

How a program can call to itself without using function.

1 visualización (últimos 30 días)
priyanka
priyanka el 12 de Oct. de 2014
Respondida: Jan el 12 de Oct. de 2014
I have to execute a program which is calling itself if an particular condition satisfies, without making that program as function.
  1 comentario
Geoff Hayes
Geoff Hayes el 12 de Oct. de 2014
Could you add some context/details as to why a program would need to call itself, and why you want to do this without making the program a function.

Iniciar sesión para comentar.

Respuesta aceptada

Jan
Jan el 12 de Oct. de 2014
Code, which calls itself controlled by a condition without being a function, sounds as a while loop.

Más respuestas (1)

Image Analyst
Image Analyst el 12 de Oct. de 2014
It is possible to have a script call itself. For example have this in test3.m:
clc;
d = dbstack;
timesCalled = length(d)
if timesCalled > 495
return; % Prevent max recursion error.
end
fprintf('Current time = %s\nType control-C to exit\n', datestr(now));
test3
Though I'm not sure how advisable this is.

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by