如何在Matlab中移动汉明窗口?

时间:2013-11-30 17:26:57

标签: matlab

我在尝试使用Matlab构建程序时得到了这条消息:

Error:
Subscript indices must either be real positive integers or logicals.

Error in Untitled (line 17)
x(pocz:kon) = x(pocz:kon) .* H;

我知道索引是错的,但我不知道应该怎么做。有谁可以帮助我?

以下是代码:

clc;
[x, fs, Nbits] = wavread('zero.wav'); % x -> data sampling | fs -> sampling freq | Nbits -> bits per sample
subplot(2,1,1); plot(x); title('asd');
N = length(x); % 
HamWin = 240; % size of Hamming Window
ShiftHamWin = 180; % shift of Hamming windwow
Frames = N/ShiftHamWin; % 
%1. PREEMFAZA
x = filter([1 -0.9735], 1, x);
%----------------------------------------------------------------
%2. OKNO
%x = x - mean(x);
beg= 0;
en = 180;
H = hamming(HamWin);
while(beg < N)
x(beg:en) = x(beg:en) .* H;
beg = round(en);
en = round(en + 180);
end;
%-----------------------------------------------------------------
subplot(2,1,2); plot(x);

1 个答案:

答案 0 :(得分:1)

我看到错误:

代码中的第13行:beg= 0;第17行:x(beg:en) = x(beg:en) .* H;

matlab中的索引不能为0。