unit Test_Vorlesung;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, TeEngine, Series, ExtCtrls, TeeProcs, Chart;
type
TForm2 =
class(TForm)
Button1: TButton;
Button2: TButton;
Chart1: TChart;
Series1: TLineSeries;
Series2: TLineSeries;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
var a: single;
{Transformationsvariable}
b,c,d,e: single;
{reele Zahlen}
m: integer;
{Anzahl der Abtastwerte}
i,j,k,l: integer;
{Laufvariable}
Zeitsignal:
array of single;
{Eingabesignal}
RE_Fd, IM_Fd, Betrag_Fd, Phase_Fd:
array of single;
{Teile d. Transformierten}
begin
m:=100;
{Vereinbarungen}
setlength(Zeitsignal,m);
setlength(RE_Fd,round(10*m/2));
setlength(IM_Fd,round(10*m/2));
setlength(Betrag_Fd,round(10*m/2));
setlength(Phase_Fd,round(10*m/2));
{Erzeugen des Zeitsignals}
for j := 0
to m - 1
do
begin
b:=0;
b:=3*sin(2*pi/m*7.1*j+0)+5*sin(2*pi/m*600.5*j+pi/2)+b;
b:=0.5*sin(2*pi/m*10.5*j+1)+4*sin(2*pi/m*123*j+2)+b;
b:=2*sin(2*pi/m*247.2*j+pi)+5*sin(2*pi/m*253*j+1)+b;
Zeitsignal[j]:=5*sin(2*pi/m*13.2*j+2*pi+5.5)+b;
{Zeitsignal mit Fensterfunktion}
//Zeitsignal[j]:=Zeitsignal[j]*(1+0.56*cos(2*pi/m*(m/2-j)));
end;
{DFT DFT DFT DFT DFT}
for j := 0
to round(10*m/2) - 1
do
begin
b:=0;
c:=0;
a:=j/10;
for i := 0
to m - 1
do
begin
b:=Zeitsignal[i]*cos(-2*pi/m*a*i)+b;
c:=Zeitsignal[i]*cos(-2*pi/m*a*i)+c;
end;
Betrag_Fd[j]:=sqrt(sqr(b)+sqr(c))*2/m;
{mit Normierung}
{Berechnung der Phase im Zeitbereich [0,2*pi}
RE_Fd[j]:=-c*2/m;
IM_Fd[j]:= b*2/m;
if RE_Fd[j]=0
then RE_Fd[j]:=999999999;
Phase_Fd[j]:=arctan(IM_Fd[j]/RE_Fd[j]);
if RE_Fd[j] <0
then Phase_Fd[j]:=pi+Phase_Fd[j];
if Phase_Fd[j]<0
then Phase_Fd[j]:=2*pi+Phase_Fd[j];
end;
chart1.series[0].clear;
chart1.series[1].clear;
for i := 0
to round(10*m/2) - 1
do
begin
chart1.Series[0].AddXY(i/10, Betrag_Fd[j]);
chart1.Series[1].AddXY(i/10, Phase_Fd[j]);
end;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
close;
end;
end.