Home > Back-end >  O bosses can't find the error output
O bosses can't find the error output

Time:09-22

# include
# include
# include
#include //the time function, so want to have the header file
# define dt/0.002/sampling interval
# define FM//25 hz
The value of the # define pai/3.14/Π
# define e/2.7/natural base
2//# define f0 initial frequency
# define dt1 0.01
# define 5 k//frequency variable slope


Void leikezibo (double * p)
{
int i;//time discrete serial number point
Double t;
Double y, mid1, mid2, mid3, mid4, mid5;
P=(double *) malloc (256 * sizeof (double));
For (I=- 128; i <=127; I++)
{
T=I * dt;
Mid1=FM pai * * t;
(mid1, mid2=pow 2);
Mid3=pow (e, mid2);
Mid4=1/mid3;
Mid5 mid2=1-2 *;
Y=mid4 * mid5;
P [I + 128]=y;
}

}

Void sind (double * p)
{
int i;
Double y, mid;
P=(double *) malloc (256 * sizeof (double));
For (I=- 128; i <=127; I++)
{
Mid=I * pai/20;
Y=sin (mid);
P [I + 128]=y;
}
}

Void xianxin (double * p)
{
int i;
Double y, mid1, t;
P=(double *) malloc (300 * sizeof (double));
{the for (I=0; i <300; I++)
T=I * dt1;
F0 pai mid1=0.1 * * * t + pai * t * * k t;
Y=cos (mid1);
[I]=y p;
}
}

Void r_noise (double * p, int n, double a)//array name, data length, noise signal strength
{
int i;
Double temp, Max;
Max=* p;
Time_t t;
Temp=32767.0/2.0;
Srand ((unsigned) time (& amp; T));
for (i=0; i If (Max & lt; Fabs (p [I]))
Max=fabs (p [I]);
If Max (Max==0.0)=1.0;
for (i=0; i {
P=p [I] [I] Max + a * * ((rand () - temp)/temp);
}
Printf (" processing array sequence is: ");
for (i=0; i Printf (" p [I] % d=% lf \ n ", I, p [I]);
}


Int main ()
{
Double * pt;
Double zy.
Void r_noise (double * p, int n, double a);
Int x;
Pt=malloc (double *);
Void leikezibo (double * p), sind (double * p), xianxin (double * p);
Printf (" input generation processing function type \ n1: ricker wavelet function \ n2: sine function \ n3: linear frequency modulation function \ n ");
Scanf_s (" % d ", & amp; x);
Printf (" input noise intensity ");
Lf scanf_s (" % ", & amp; Zy);
The switch (x)
{
Case 1: leikezibo (pt); R_noise (pt, 256, zy); break;
Case 2: sind (pt); R_noise (pt, 256, zy); break;
Case 3: xianxin (pt); R_noise (pt, 300, zy); break;
Default: printf (" \ "a);
}
}

CodePudding user response:

Allocate memory anywhere to indicate size, such as pt=(double *) malloc (sizeof (double));

CodePudding user response:

Debug: pt a print on the change after the pt, so you know that the problem is in front of the function, or behind, so that gradually print can determine the position of the error of
Is another important, manual application of last to manually set the memory space, or it will cause a memory leak
Printf (" p [I] % d=% lf \ n ", I, p [I]); And it is you want to printf (" p=% [% d] lf \ n ", I, p [I]); Let it be
  • Related