-3

I got this message whilst trying to build a program in Matlab:

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

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

I know that the index is wrong but i do not know how should it be. Could anyone help me ?

Here is the code:

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);
Dennis Jaheruddin
  • 21,208
  • 8
  • 66
  • 122
  • 2
    See how to ask properly in SO [ask] – Luis Mendo Nov 30 '13 at 17:29
  • See [this question](http://stackoverflow.com/questions/20054047/subscript-indices-must-either-be-real-positive-integers-or-logicals-generic-sol) for [the general way to deal with this error message](http://stackoverflow.com/a/20054048/983722). -- Edited question to be more suitable for this site. – Dennis Jaheruddin Dec 04 '13 at 15:41

1 Answers1

1

Error that I see:

line 13 in your code: beg= 0; line 17: x(beg:en) = x(beg:en) .* H;

Index can not be 0 in matlab.

Alamakanambra
  • 5,845
  • 3
  • 36
  • 43