🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.soft-sys.matlab
Article #21

SOURCE: clocksub.m - compute time difference

#21
From: Michael Maurer
Date: Sat, 23 Jan 1993 01:09
76 lines
2790 bytes
Hoping to start a trend, here is an unsolicited matlab m-file.
CLOCKSUB computes the number of seconds elapsed between two calls to
CLOCK.  (Has trouble with year boundaries due to leap-year
irregularities.)  Suggested improvements are welcome.

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	clocksub.m
#	mod.m
# This archive created: Fri Jan 22 16:57:09 1993
export PATH; PATH=/bin:$PATH
echo shar: extracting "'clocksub.m'" '(583 characters)'
if test -f 'clocksub.m'
then
	echo shar: will not over-write existing file "'clocksub.m'"
else
sed 's/^XX//' << \SHAR_EOF > 'clocksub.m'
XXfunction dt=clocksub(t2,t1)
XX
XX%CLOCKSUB
XX%	dt=clocksub(t2,t1) returns the time difference in seconds between
XX%	the two times (t2-t1).  See CLOCK for format of t1 and t2.
XX
XX%	Michael Maurer, 25 June 1992
XX%	Copyright (c) 1993 by Michael Maurer
XX
XXd=t2-t1;
XXmonths=[0 31 31 28 30 31 30 31 31 30 31 30 31];
XXif d(1),
XX   error('can''t handle different years yet (leap day complication)')
XXend
XX
XXdt=d(1);
XXm1=sum(months(1:t1(2))) + ((mod(t1(1),4)==0) & t1(2)>3);
XXm2=sum(months(1:t2(2))) + ((mod(t2(1),4)==0) & t2(2)>3);
XXdt=dt*365 + (m2-m1) + d(3);
XXdt=dt*24 + d(4);
XXdt=dt*60 + d(5);
XXdt=dt*60 + d(6);
SHAR_EOF
if test 583 -ne "`wc -c < 'clocksub.m'`"
then
	echo shar: error transmitting "'clocksub.m'" '(should have been 583 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'mod.m'" '(225 characters)'
if test -f 'mod.m'
then
	echo shar: will not over-write existing file "'mod.m'"
else
sed 's/^XX//' << \SHAR_EOF > 'mod.m'
XXfunction y=mod(x,n)
XX%MOD	Y = MOD(X, N) returns X modulo N.
XX
XX%	Michael Maurer, Sep 10 1990
XX%	Copyright (c) 1993 by Michael Maurer
XX
XXif (length(n)~=1),
XX   error('The base N must be size 1x1.');
XXend
XX
XXy = abs(x - (floor(x/n)*n));
SHAR_EOF
if test 225 -ne "`wc -c < 'mod.m'`"
then
	echo shar: error transmitting "'mod.m'" '(should have been 225 characters)'
fi
fi # end of overwriting check
#	End of shell archive
exit 0
--
______________________________________________________________________
Michael Maurer          maurer@nova.stanford.edu        (415) 723-1024
Technical Details
Message-ID: <maurer.727751379@nova.Stanford.EDU>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!nntp.Stanford.EDU!forsythe.stanford.edu!nova!maurer

Show Full Headers
Complete Article Headers
Newsgroups: comp.soft-sys.matlab
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!nntp.Stanford.EDU!forsythe.stanford.edu!nova!maurer
From: Michael Maurer <maurer@nova.stanford.edu>
Subject: SOURCE: clocksub.m - compute time difference
Message-ID: <maurer.727751379@nova.Stanford.EDU>
Sender: news@leland.Stanford.EDU (Mr News)
Organization: STAR Lab, Stanford University, California USA
Date: 23 Jan 93 01:09:39 GMT
Lines: 76