Category : Pascal Source Code
Archive   : CONVOLV.ZIP
Filename : CONVOLV.PAS

 
Output of file : CONVOLV.PAS contained in archive : CONVOLV.ZIP
program convolv;

uses
crt;


var
lenX, lenH, lenY, code : integer;
numTerms : integer;
i,j : integer;
temp : string[10];
x,h,y : array[0..30] of real;

begin
clrscr;
writeln('This program computes the convolution of signal X(k) with');
writeln('transfer function H(k), yielding response Y(k).');
writeln;
writeln('Enter the length of the input X(k)');
readln(temp);
val(temp,lenX,code);
writeln('Enter the length of the function H(k)');
readln(temp);
val(temp,lenH,code);

{determine the length of the result}
lenY := lenX + lenH -1;
{determine the length of the table to compute values}
numTerms := lenX + 2 * (lenH-1);

{pad input array with zeroes}
for i := 0 to 30 do
x[i] := 0;
{read in input values, shifted by lenH-1}
for i := 0 to (lenX-1) do
begin
write('X(',i,') = ');
readln(temp);
val(temp,x[i+lenH-1],code);
end;

{read in transfer function}
writeln;
for i := 0 to (lenH-1) do
begin
write('H(',i,') = ');
readln(temp);
val(temp,h[i],code);
end;
writeln;

writeln('The length of the result is ',lenY);

{compute the convolution, where y(k)=SUM (x(k)*h(n-k))}
for i := 0 to (lenY-1) do
begin
y[i] := 0;
for j := 0 to (lenH-1) do
y[i] := y[i] + x[i+j]*h[lenH-1-j];
end;

writeln;
for i := 0 to (lenY-1) do
writeln('Y(',i,') = ',y[i]);

writeln('Hit to end.');
readln;
end.

  3 Responses to “Category : Pascal Source Code
Archive   : CONVOLV.ZIP
Filename : CONVOLV.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/