Code covered by the BSD License  

Highlights from
Numerical Computing with Simulink, Vol. 1

image thumbnail
from Numerical Computing with Simulink, Vol. 1 by Richard Gran
This sequel to Numerical Computing with MATLAB explores the mathematics of simulation.

reset_time(Time)
function reset_time(Time)

if Time == 0; return; end
hGUI=evalin('base','hGUI');
h  = guidata(hGUI);

AMPM = 'am';

if Time > 100
    AMPM =  'pm';
    Time =  Time - 100;
end 

Hr  = fix(Time);
Min = fix(100*(Time-Hr));
if Min < 10
    Mins = ['0' num2str(Min)];
else
    Mins = num2str(Min);
end
Hrs = num2str(Hr);

if Min >59 || Hr >12
    Mins = ['E' 'E'];
    Hrs  = ['E' 'E'];
end

if Time ~=0
    set(h.text15,'String',Hrs)
    set(h.text13,'String',Mins)
    set(h.text11,'String',AMPM)
end

Contact us at files@mathworks.com