MATLAB: Kurtosis ignoring 0s in matrix kurtosis Hi there, I was wondering I have a matrix A of size 295×34. I want to do the kurtosis, but want to ignore all zeros. How can I do this? Best Answer out = cellfun(@(x)kurtosis(x(x~=0)),num2cell(A,1));ors = sum(A~=0);x1 = bsxfun(@minus,A,sum(A)./s);x1(A == 0) = 0;out = s.*sum(x1.^4)./ sum(x1.^2).^2; Related SolutionsMATLAB: How to sum the elements of a symbolic vector syms x1 x2X = [1, x1, x2, x1^2, x2^2, x1*x2], out=char(X(1))for k=2:numel(X) out=[out '+' char(X(k))]end MATLAB: Standard deviation ignoring 0s in matrix One easy way would be to convert all zeros to NaN, and then use the nanstd function to ignore the NaNs in the std calculation.Absy(Absy==0)=NaN;s = nanstd(Absy,[],1); %column by column std deviation Related QuestionHow to compute KurtosisHow to properly sum 3D matrixesHow to ignore the first few 0s in a vector but not ignore the 0s in the middleHow to generate random numbers in mixture normal distribution (considering weight)
Best Answer