【问题标题】:How to correctly split a signal in matlab?如何在matlab中正确分割信号?
【发布时间】:2014-12-13 10:38:51
【问题描述】:

我目前正在努力在 Matlab 中正确拆分信号。 如果我有一个假设为3 秒长的音频信号,采样率为fs,并且我想进一步使用从第二个2 到第二个3rd 的片段,我该如何实现呢? 一些伪代码:

[y,fs] = audioread('Aaaaaaa.wav');       
N = length(y);
y_sub =...%get a 1 second long fragment of the original signal starting from 2 seconds

我希望我想达到什么目的很清楚?

非常感谢 Stackoverflow!

【问题讨论】:

    标签: arrays matlab matrix signals signal-processing


    【解决方案1】:

    您可以创建一个时间数组并在您的代码中使用它,

    [y,fs] = audioread('Aaaaaaa.wav');       
    N = length(y);
    t = (0 : N-1)/fs;
    y_sub = y((t>1)&(t<=3));
    

    或者您可以直接使用示例,

    t1 = 1;
    t2 = 3;
    sample1 = t1 * fs + 1;
    sample2 = t2 * fs + 1;
    y_sub = y(sample1:sample2); % Its 1<=t<=3
    

    之所以使用+1,是因为t0开始,而样本从1开始。

    【讨论】:

    • 谢谢!你能解释一下最后一行吗?我不太确定我是否理解正确。
    • @user3488736 它选择y 的值,其中1&lt;t&lt;=3 这就是你想要的。
    猜你喜欢
    • 2011-09-11
    • 1970-01-01
    • 2016-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-25
    • 2013-08-26
    相关资源
    最近更新 更多