📄 mmm.java
字号:
package fft;
/**
* 此处插入类型描述。
* 创建日期:(2003-10-9 19:15:50)
* @author:Administrator
*/
import java.io.*;
import java.awt.Graphics;
import java.awt.*;
import java.applet.Applet;
public class Mmm extends Applet {
public static DoFFT usefft;
public static String s;
public static double output[];
public static int N = 64;
private static double test[];//2003.12.9
public static double testArray[][];
Dimension d; //定义画布尺寸
//在此处用来启动应用程序的代码。
public void start() {
// 直接读二进制文件,输出幅值
s = new String("1070854414896");
// s = new String("fft");
output = new double[N];
usefft = new DoFFT(s);
test = new double[N];
for(int i=0;i<N;i++){
test[i]=Math.exp(-0.1*i);
}
//output = usefft.fft_sy(test);//2003.12.9 付立叶变换
// output = usefft.fft_sy(usefft.input);//付立叶变换
output = usefft.powerspetrum(usefft.input);//功率谱分析
// output = usefft.cepstrum(usefft.input);//倒频谱分析
for (int i = 0; i < N; i++) {
// output[i]=20*Math.log(Math.abs(output[i]))/Math.log(10);
//线性幅值与对数幅值
// System.out.println(i + " " + (float)output[i]);
}
//return output;
} //end of method
public void paint(Graphics g) {
float xcur = 0, xprev = 0, ycur = 0, yprev = (float)output[0], ymax = 0;
// d = size();
for (int i = 0; i < N; i++) {
ycur = (float) output[i];
if (ycur > ymax) {
ymax = ycur;
}
}
//System.out.println( " \n Ymax = " + ymax);
yprev=200-200*yprev/ymax;
g.setColor(Color.black);
for (int i = 0; i < N/2; i ++) {
ycur = (float) output[i];
ycur=200-200*ycur/ymax;
g.drawLine(Math.round(xprev),Math.round(yprev),Math.round(xcur),Math.round(ycur));
xcur += 1;
xprev = xcur;
yprev = ycur;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -