将相似的 y 值分组并获取 x 值 - 使用八度/matlab

grouping similar values of y and getting the x values - using octave / matlab

我导入了语音音频信号,我正在尝试查找 t(时间线)的所有值及其索引,其中 yy2 (音频信号)值相似。

我可以使用 histcyy2 值进行分组,但是我怎样才能得到它以便我知道 t 的值对于分组的 yy2 值?

我是否应该为此使用 histc,因为箱子(图中使用的总条形)将超过 10 个?

我的想法在哪里:

  1. yy2.
  2. 的相似值进行分组
  3. 获取每个分组的 yy2 值相似的 t 值。

在下面的代码中,yy2模拟导入的音频信号

clear, clc, clf,close all

pkg load signal

fs_rate=8000
len_of_sig=1.5; %length of signal in seconds
t=linspace(0,len_of_sig,fs_rate*len_of_sig);
yy2=.5*sin(2*pi*3*t)+.3*sin(2*pi*2.2*t);

subplot(2,1,1);plot(t,yy2,'-*');
subplot(2,1,2);hist(yy2)

情节:

Ps: 我正在使用类似于 matlab 的 Octave 4.2.2。

如果您想要 t 的索引和值组,其中 yy2 值相似:

% Get uniqe valuse of yy2
unique_vals = unique(yy2);

% Get index groups for each unique yy2 value in a cell array
index_groups = arrayfun(@(v) find((yy2 == v)),unique_vals,'UniformOutput',false);

% Get t groups for each unique yy2 value in a cell array
t_groups = cellfun(@(v) t(v),index_groups,'UniformOutput',false);

% Get yy2 groups for each unique yy2 value in a cell array (not really required)
yy2_groups = cellfun(@(v) yy2(v),index_groups,'UniformOutput',false);