Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

The following C program is to implement the pair of lowpass and highpass filters.

Status
Not open for further replies.

jaya krishna

Member level 1
Joined
May 10, 2012
Messages
41
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
India,coimbatore
Activity points
1,770
The following C program is to implement the pair of lowpass and highpass filters.


any body pls rectifies the error..it shows the error is segmentation fault...

i want to print the value of High and low it show in the program...pls any body tell me...

#include <stdio.h>
#define N 16
#define N1 15
void main()
{
int n;
double buf[N]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}, h[N]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, top, bottom, low, high;
FILE *in, *filt, *out1, *out2;
in = fopen("signal.dat", "r");
filt = fopen("filter.dat", "r");
out1 = fopen("lpf.dat", "w");
out2 = fopen("hpf.dat", "w");
//for (n=0; n<N; n++)
//fscanf (filt, "%lf\n", &h[n]); // Read LPF coefficients
for (n=0; n<=N1; n++)
buf[n] = 0.; // Initialize buffer with zero
//while ( !feof(in) ) // As long as there is data in the file,
{ // the filtering process is continued.
//fscanf (in, "%lf\n", &buf[0]);
top = bottom = 0.;
for (n=0; n<N; n=n+2)
top = top + h[n]*buf[n]; // Even indexed coefficients

for (n=1; n<N; n=n+2)
bottom = bottom + h[n]*buf[n]; // Odd indexed coefficients

low = top + bottom; // Compute LPF output
high = top - bottom; // Compute HPF output

printf("low:%f",low);
printf("HPF:%f",high);

fprintf (out1, "%f\n", low);
fprintf (out2, "%f\n", high);

for (n=N1; n>0; n--)
buf[n] = buf[n-1]; // Update buffer
}
fclose(in);
fclose(filt);
fclose(out1);
fclose(out2);
}



by
jai
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top