home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_10_05
/
1005048a
< prev
next >
Wrap
Text File
|
1992-03-11
|
854b
|
31 lines
Listing 1. Impulse response function
#include <stdio.h>
void impulse_response(FILE *out, int N,
double a, double b, double c)
{
double
y = c, /* The most recent system output value */
y1 = 0; /* The previous output */
/* Time t = 0, before the impulse. */
fprintf(out, "%lg\n", y1);
/* Time t = 1, the instant of the impulse. */
fprintf(out, "%lg\n", y);
N -= 2; /* Two points already written */
/* All later times, t > 1 */
while(N-- >= 0)
{
double t = y;
y = a*y + b*y1;
y1 = t;
fprintf(out, "%lg\n", y);
}
}