필터 지우기
필터 지우기

How a program can call to itself without using function.

조회 수: 1 (최근 30일)
priyanka
priyanka 2014년 10월 12일
답변: Jan 2014년 10월 12일
I have to execute a program which is calling itself if an particular condition satisfies, without making that program as function.
  댓글 수: 1
Geoff Hayes
Geoff Hayes 2014년 10월 12일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2014년 10월 12일
Code, which calls itself controlled by a condition without being a function, sounds as a while loop.

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 10월 12일
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.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by