manage time computing
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
I would like to manage the computing time of a function. For example :
function y = myfun(x)
y = something_long_to_calculate(x);
return
and I would like my main code to do something like:
lim = 5; %time limit in sec
x = 0;
tic;
while toc<lim
y = myfun(x);
end
Obviously, I wouldn't work, the point is how could you limited the time of calculation. In this case, if y should have been a vector 100x1 and the program would just have had time to compute the 10 first iterations, how could I still got those values ?
thx
댓글 수: 0
채택된 답변
Walter Roberson
2011년 12월 20일
That looks like it would work. For a different coding, see http://www.mathworks.com/matlabcentral/answers/21721-constructing-for-loop-in-terms-of-seconds
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Downloads에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!