Matlab-Funktion zur Rückgabe der verstrichenen Zeit seit dem ersten Funktionsaufruf
Diese einfache Matlab-Funktion ist nützlich als Wanduhr-Verstrichene-Zeit-Anbieter, z.B. für Simulink-Modelle. Sie gibt die verstrichene Zeit in Sekunden seit dem ersten Funktionsaufruf zurück.
elapsed_time_since_first_call.m
function t = elapsedTime()
%ELAPSEDTIME Returns wall clock seconds since the first call.
% t = ELAPSEDTIME() returns the number of seconds passed since the first
% call to this function (wall clock time).
persistent t0
if isempty(t0)
t0 = tic; % Start timer on the first call
end
t = toc(t0); % Elapsed time since first call
endSie können dies in Matlab oder in einem Simulink-Modell verwenden:

Check out similar posts by category:
Matlab/Simulink
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow