MATLAB: Subscript indices must either be real positive integers or logicals. I have FastICA code from Pryathm. BUT, i get error

error

[x1, Fs1] = wavread('C:\Users\Ariyanto\Documents\TA\Data TA\data sakit via telpon\par1.wav');
[x2, Fs2] = wavread('C:\Users\Ariyanto\Documents\TA\Data TA\Blank Sound\blank.wav');
A = x1';
B = x2';
n=numel(A);
m=numel(B);
m1=floor(m/n);
h=zeros(1,n);
h(1:m-m1*n)=1;
v2=cumsum(ones(1,n)*m1+h);
v1=[1 v2(1:end-1)+1];
C=[A;arrayfun(@(x) mean(B(v1(x):v2(x))),1:n)]; % Combining 2 signals
m = size(x1,1); % size of each signal
n = 2; % Number of sound sources
A = randn(n, n); % Random 2 X 2 mixing matrix
x = A*C; % Mixed signals
mx = sum(x, 2)/m; % supposed to be the mean; E{x}
x = x - repmat(mx, 1, m); % x - E{x}
for i = 1:n % This step is done
xi = x(i,:); % to whiten the data
[E, D] = eig(xi*xi'); % (make variance one
xi = E*sqrtm(inv(D))*E'*xi; % and uncorrelate the data)
x(i,:) = xi;
end
w = randn(n, 1); % Random weight vector
w = w/norm(w,2); % make 'w' a unit vector
w0 = randn(n, 1);
w0 = w0/norm(w0, 2);
while abs(abs(w0'*w)-1) > 0.000001
w0 = w;
c = cov(x');
cc = inv(sqrtm(c));
x = cc*x;
G = tanh(x);
DG = diff(G);
w = round(w);
w = x.*G(w'*x)'/m - sum(DG(w'*x))*w/m; % This line come to error
% This step is supposed to perform:
% w = E{xg(w^{T}*x)} - E{g'(w^{T}*x)}w
w = w/norm(w, 2);
end
sound(w'*x, 8000); % Supposed to be one of the original signals
plot(w'*x);
Anyone can solve this?

Best Answer

Since you haven't given use the full text of the error message, particularly the bit that shows which line causes the error, we can't tell what the problem is.
However, this is something that you can find out for yourself by debugging your program. At the comment prompt,
dbstop if error
then run your program and when it breaks into the debugger because of the error, look at the value of the index and figure out why it's not an integer or is less than 1. If necessary rerun your program step by step as described in the above link.