Skip to content

Commit

Permalink
more complex function as example
Browse files Browse the repository at this point in the history
  • Loading branch information
dmidem authored and Dmitry Demin committed Sep 13, 2015
1 parent b6c7e5a commit 7975733
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions filter_test.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#include <stdio.h>
#include <math.h>

#include "filter.h"
#include "dumper.h"

double f(const double t)
{
return sin(t) * sin(t * 0.1);
}

int main()
{
double snum[] = { 1 };
double sden[] = { 1, 1 };
double sden[] = { 1 };

double dT = 0.01;
int L = 1;
double dT = 0.1;
int L = 10;
double tmax = 0.2;

int nsnum = sizeof(snum) / sizeof(snum[0]);
Expand All @@ -23,9 +29,13 @@ int main()
print_polynom_nd(iir->b, iir->m + 1, iir->a, iir->n + 1, 'z', "IIR H(z)");

printf("t\tx\ty\n");
double t, x, y;
double t, x = 0, y;
int l = 0;
for (t = 0; t < tmax; t += dt) {
x = 1;
if (--l <= 0) {
x = f(t);
l = L;
}
y = iir_filter_next(iir, x);
printf("%f\t%f\t%f\n", t, x, y);
}
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ EXE=filter_test
CC=gcc
CFLAGS=-Wall -O3
#LDFLAGS=-static-libgcc -static-libstdc++ -static
LDFLAGS=
LDFLAGS=-lm
RM=rm

all: $(EXE)
Expand Down

0 comments on commit 7975733

Please sign in to comment.