Does anyone know how to do this problem
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MATLAB has timing functions that allow your program to monitor how much time has elapsed. These are called tic and toc. The function toc returns the amount of time since the last tic. Use a while loop to do the following for a total of 4 seconds. Every 0.3 seconds print, using fprintf, the message “The elapsed time is:” followed by the elapsed time.
1 commentaire
Réponses (1)
David Sanchez
le 5 Nov 2014
tic
lim = 0.3;
N=1;
while toc<.61
%%%%%
a=rand;%whatever your program does here
%%%%%
tmp = toc;
if tmp>lim
fprintf('The elapsed time is %g\n', tmp)
N=N+1;
lim=lim*N;
end
end
1 commentaire
David Sanchez
le 5 Nov 2014
obviously, you chane .61 by 4 to cover up your case
...
while toc < 4
...
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!