I'm trying to define a new matrix astar using the individual elements from a and X that correspond to the new matrix. MATLAB is showing this error:
Index in position 2 exceeds array bounds (must not exceed 4).Error in newalg (line 13) if X(ii,jj) >= 0 || X(ii,jj) == 0
Could anyone help me debug and improve my code?
load('data');W = waveletfunction(6);B = W * data;A = B(1:243,:);mu = max(A,[],'all');v = min(A,[],'all');a = (2.*A - mu - v)/(mu - v);X = laplacei(243,4);n = numel(X);astar = zeros(size(X));for ii = 1:n for jj = 1:n if X(ii,jj) >= 0 || X(ii,jj) == 0 astar(ii,jj) = (1 - 1/(1 + exp(-a(ii,jj)))) * X(ii,jj); else astar(ii,jj) = (1/(1 + exp(-a(ii,jj)))) * X(ii,jj); end endenddisp(astar)
Best Answer