没有合适的资源?快使用搜索试试~ 我知道了~
C语言实现数字信号处理算法
需积分: 13 17 下载量 119 浏览量
2010-09-14
19:47:26
上传
评论 1
收藏 147KB PDF 举报
温馨提示
试读
12页
一些用C语言写的有关信号处理的算法,有关于fft,数字滤波器,模拟滤波,多项式,贝塞尔拟合等
资源推荐
资源详情
资源评论
中国科学技术大学电子工程与信息科学系 多媒体通信实验室 (Copyright 2000)
附录 A C语言实现数字信号处理算法
附录 A1 BC 下复数类型的实现
本部分内容可以在http://202.38.75.33/dsp/C/ComplexUse.cpp获得。
1、利用 BC 提供的复数支持
//BC
中使用复数类型使用示例
(ComplexUse.Cpp
文件
)
#include <iostream.h>
#include <complex.h>
int main(void)
{
double x = 3.1, y = 4.2;
complex z = complex(x,y);
cout << "z = "<< z << "";
cout << " and imaginary real part = " << imag(z) << "";
cout << "z has complex conjugate = " << conj(z) << " ";
return 0;
}
2、定义复数类,填写相应成员函数
//C
中的复数类型调用时可能不是非常好用,可自己定义复数类
(ComplexUse.Cpp
文件
)
class Complex{
public:
Complex(){}
Complex( float re, float im );
float r(){return real;};
float i(){return imag;};
float mod(){return sqrt(real*real+imag*imag);};
Complex operator+( Complex &other );
Complex operator-( Complex &other );
Complex operator*( Complex &other );
Complex operator/( Complex &other );
private:
float real, imag;
};// Operator overloaded using a member function
Complex::Complex(float re,float im){
如果您在阅读过程中发现疏漏和错误,请您尽快和编者取得联系 network@ustc.edu.cn cxh@ustc.edu.cn
中国科学技术大学电子工程与信息科学系 多媒体通信实验室 (Copyright 2000)
real=re;
imag=im;
};
Complex Complex::operator+( Complex &other ){
return Complex( real + other.real, imag + other.imag );
};
Complex Complex::operator-( Complex &other ){
return Complex( real - other.real, imag - other.imag );
};
Complex Complex::operator*( Complex &other ){
float x,y;
x=real*other.real-imag*other.imag;
y=real*other.imag+imag*other.real;
return Complex( x,y );
};
Complex Complex::operator/( Complex &other ){
float x,y,l;
l=other.real*other.real+other.imag*other.imag;
x=real*other.real+imag*other.imag;
y=other.real*imag-real*other.imag;
x=x/l;
y=y/l;
return Complex(x,y);
};
附录 A2 BC 下的绘图
本部分内容可以在http://202.38.75.33/dsp/C/PlotByBC.cpp获得。
1、通用绘图函数的有关说明
(1)函数输入参数说明
left : 绘图区的左上角横坐标
top : 绘图区的左上角纵坐标
right : 绘图区的右下角横坐标
bottom : 绘图区的右下角纵坐标
f : 需要绘制图形的数组
length : f 数组的长度
(2)函数调用示例
//在以(10,5)为左上角坐标,(200,240)为右下角坐标的区域内绘制数组 x 的图形,数组长度为 10
Plot(10,5,200,240,x,10);
(3)BC 图形程序需要“BC 安装目录\bgi\egavga.bgi”文件支持
如果您在阅读过程中发现疏漏和错误,请您尽快和编者取得联系 network@ustc.edu.cn cxh@ustc.edu.cn
中国科学技术大学电子工程与信息科学系 多媒体通信实验室 (Copyright 2000)
2、通用绘图函数
void Plot(int left,int top,int right,int bottom,double *f,int length)
{
int n;
int Left,Top,Right,Bottom,Mid;
double x_unit_length,y_unit_length,max=-1.0;
for(n=begin;n<=end;n++) //begin 和 end 表示数组下标的起始值和结束值
if(max<fabs(f[n]))
max=fabs(f[n]);
Left=left+5;Top=top+5;
Right=right-5;Bottom=bottom-5;
Mid=(Bottom+Top)/2;
x_unit_length=(Right-Left)/(N+2);
y_unit_length=(Bottom-Mid)/max;
int gdriver = DETECT, gmode;
initgraph(&gdriver, &gmode, "");
rectangle(left,top,right,bottom);
setcolor(YELLOW);
setcolor(GREEN);
int x;
x=Left+x_unit_length/2;
n=0;
while(n<length) {
line(x,Mid,x,Mid-f[n]*y_unit_length);
x+=x_unit_length;
n++;
}
setcolor(LIGHTGRAY);
getch();
closegraph();
}
附录 A3 傅立叶变换有关算法
本部分内容可以在http://202.38.75.33/dsp/C/DFT-FFT.cpp获得。
1、傅立叶变换数值计算函数
/* 输入参数:
f : 需要进行傅立叶变换的数值序列
N : 输入序列的长度
M : 频谱分析的频点数
如果您在阅读过程中发现疏漏和错误,请您尽快和编者取得联系 network@ustc.edu.cn cxh@ustc.edu.cn
剩余11页未读,继续阅读
资源评论
xiebee
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- J211-T1B-A-VB一款SOT23封装P-Channel场效应MOS管
- J210-VB一款SOT23封装P-Channel场效应MOS管
- content_1713924059748.zip
- J210-T1B-A-VB一款SOT23封装P-Channel场效应MOS管
- Suno V3 AI音乐生成神器,助你秒变音乐大师,suno AI音乐使用教程
- 自适应极化滤波完成P/S波分离
- 0b40adff-950d-44cf-88e6-f4a64292b638.apk
- J209-VB一款SOT23封装P-Channel场效应MOS管
- OLED12864模块(IIC接口)中文说明书.pdf
- 22304010116工管余文贤.bak
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功