tic while(toc<60) % code end
How I can create a while cycle that ends after a sepecific time
4 次查看(过去 30 天)
显示 更早的评论
my aim is make a wile cilce that run for a specific time T. For exemple
T=60 %sec
while(t==60)
t=time.
for i=0:10
d=sum(i+)
.
.
.
.
.
.
end
end
%where t start from zero and go on whit the time
%t is 1 after 1 second
0 个评论
采纳的回答
更多回答(1 个)
Eric Sofen
2023-1-4
I think timer is likely to give you better precision for this sort of thing than tic/toc (tic/toc is better for timing performance of a function or script). The reference page for timer illustrates exactly this while-loop scenario.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!