加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

雷克子波C程序

(2022-10-28 16:11:11)
标签:

雷克子波c程序

分类: 《信号分析与处理》课
#include "stdio.h"  // standard input/output head file.
#include "math.h"  // math. head file.
#include "malloc.h"  // memory allocation head file.
#define fm  35   // The main frequency of Ricker wavelet, you can change it.  
#define dt  0.002  // The sample interval, you can also set it to 0.001 or 0.004.
#define XL  0.060  // The length of wavelet(s), you can change it.
#define PI 3.1415926

main()
{
  FILE *fp;
  float *x; // define the dynamic array.
  float t;
  int i,M;

  M=XL/dt+1;  // The number of x(t).

  printf("x(M),M=M\n",M);

// allocate dynamic array.
  x=(float *)calloc(M,sizeof(float));
// Generate Ricker wavelet.

  fp=fopen("Ricker.xls","w");
  for(i=-M/2;i<=M/2;i++)
    { t=i*dt;
      x[i+M/2]=(1.0-2.0*pow(PI*fm*t,2.0))*exp(-pow(PI*fm*t,2.0));
      fprintf(fp,"%8.3f \t .4f\n ",t*1000,x[i+M/2]);
    }
  fclose(fp);
}

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有