Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 具有特定相位和频率的FFT后的波形预测_R_Signal Processing_Fft_Prediction - Fatal编程技术网

R 具有特定相位和频率的FFT后的波形预测

R 具有特定相位和频率的FFT后的波形预测,r,signal-processing,fft,prediction,R,Signal Processing,Fft,Prediction,我使用滑动窗口从我的脑电图数据中提取信息,并使用FFT。现在我想预测从我的窗口到下一个窗口的信号。所以我从一个0.25秒的时间窗口中提取相位来预测下一个0.25秒的时间窗口 我不熟悉信号处理/预测,所以我在这里的知识有些生疏 我无法用提取的相位和频率生成正弦波。我只是没有找到解决办法。我可能只需要往正确的方向推一下,谁知道呢 R中是否有一个函数可以帮助我生成合适的正弦波 所以我提取了相位的最大频率,需要用这些信息生成一个波。这里是合成所选频率正弦曲线的伪代码。。。目前,它假设初始种子相移为零,因

我使用滑动窗口从我的脑电图数据中提取信息,并使用FFT。现在我想预测从我的窗口到下一个窗口的信号。所以我从一个0.25秒的时间窗口中提取相位来预测下一个0.25秒的时间窗口

我不熟悉信号处理/预测,所以我在这里的知识有些生疏

我无法用提取的相位和频率生成正弦波。我只是没有找到解决办法。我可能只需要往正确的方向推一下,谁知道呢

R中是否有一个函数可以帮助我生成合适的正弦波


所以我提取了相位的最大频率,需要用这些信息生成一个波。

这里是合成所选频率正弦曲线的伪代码。。。目前,它假设初始种子相移为零,因此如果需要不同的初始相移,只需改变θ值即可

func pop_audio_buffer(number_of_samples float64, given_freq float64,
    samples_per_second float64) ([]float64, error) {

    // output sinusoidal curve is assured to both start and stop at the zero cross over threshold,
    // independent of supplied input parms which control samples per cycle and buffer size.
    // This avoids that "pop" which otherwise happens when rendering audio curves
    // which begins at say 0.5 of a possible range -1 to 0 to +1


    int_number_of_samples := int(number_of_samples)

    if int_number_of_samples == 0 {

        panic("ERROR - seeing 0 number_of_samples in pop_audio_buffer ... float number_of_samples " +
            FloatToString(number_of_samples) + " is your desired_num_seconds too small ? " +
            " or maybe too low value of sample rate")
    }

    source_buffer := make([]float64, int_number_of_samples)

    incr_theta := (2.0 * math.Pi * given_freq) / samples_per_second

    theta := 0.0

    for curr_sample := 0; curr_sample < int_number_of_samples; curr_sample++ {

        source_buffer[curr_sample] = math.Sin(theta)

        theta += incr_theta
    }

    return source_buffer, nil

} //      pop_audio_buffer
func pop\u audio\u buffer(采样数浮点数64,给定频率浮点数64,
每秒采样数浮点64)([]浮点64,错误){
//输出正弦曲线确保在过零阈值处启动和停止,
//与提供的输入参数无关,输入参数控制每个周期的样本数和缓冲区大小。
//这避免了渲染音频曲线时出现的“弹出”
//从-1到0到+1的可能范围的0.5开始
样本的数量:=int(样本的数量)
如果int_样本数_==0{
恐慌(“错误-在pop\u音频\u缓冲区中看到0个\u样本…浮点\u样本数”+
FloatToString(样本数)+“所需的秒数是否太小?”+
“或者可能采样率值太低”)
}
source\u buffer:=make([]浮点64,整数\u个样本)
增量:=(2.0*math.Pi*给定频率)/每秒采样数
θ:=0.0
对于当前样本:=0;当前样本<当前样本的整数;当前样本++{
source\u buffer[curr\u sample]=math.Sin(θ)
θ+=增量θ
}
返回源缓冲区,无
}//pop_音频_缓冲区

这里是合成选定频率正弦曲线的伪代码。。。目前,它假设初始种子相移为零,因此如果需要不同的初始相移,只需改变θ值即可

func pop_audio_buffer(number_of_samples float64, given_freq float64,
    samples_per_second float64) ([]float64, error) {

    // output sinusoidal curve is assured to both start and stop at the zero cross over threshold,
    // independent of supplied input parms which control samples per cycle and buffer size.
    // This avoids that "pop" which otherwise happens when rendering audio curves
    // which begins at say 0.5 of a possible range -1 to 0 to +1


    int_number_of_samples := int(number_of_samples)

    if int_number_of_samples == 0 {

        panic("ERROR - seeing 0 number_of_samples in pop_audio_buffer ... float number_of_samples " +
            FloatToString(number_of_samples) + " is your desired_num_seconds too small ? " +
            " or maybe too low value of sample rate")
    }

    source_buffer := make([]float64, int_number_of_samples)

    incr_theta := (2.0 * math.Pi * given_freq) / samples_per_second

    theta := 0.0

    for curr_sample := 0; curr_sample < int_number_of_samples; curr_sample++ {

        source_buffer[curr_sample] = math.Sin(theta)

        theta += incr_theta
    }

    return source_buffer, nil

} //      pop_audio_buffer
func pop\u audio\u buffer(采样数浮点数64,给定频率浮点数64,
每秒采样数浮点64)([]浮点64,错误){
//输出正弦曲线确保在过零阈值处启动和停止,
//与提供的输入参数无关,输入参数控制每个周期的样本数和缓冲区大小。
//这避免了渲染音频曲线时出现的“弹出”
//从-1到0到+1的可能范围的0.5开始
样本的数量:=int(样本的数量)
如果int_样本数_==0{
恐慌(“错误-在pop\u音频\u缓冲区中看到0个\u样本…浮点\u样本数”+
FloatToString(样本数)+“所需的秒数是否太小?”+
“或者可能采样率值太低”)
}
source\u buffer:=make([]浮点64,整数\u个样本)
增量:=(2.0*math.Pi*给定频率)/每秒采样数
θ:=0.0
对于当前样本:=0;当前样本<当前样本的整数;当前样本++{
source\u buffer[curr\u sample]=math.Sin(θ)
θ+=增量θ
}
返回源缓冲区,无
}//pop_音频_缓冲区