MATLAB: Sum of rand matrix equal to zero sum of all is zero Dear All, I want to generate matrix A ,i.e. n by n random matrix but the sum(sum(A)) = zero. Help in this regard will be highly appreciated…….. Regards………. Best Answer Subtract the mean from the samples:n=10; z=randn(n,n); z=z-sum(sum(z))/(n*n); sum(sum(z)) Related SolutionsMATLAB: Random numbers with mean-correction http://www.mathworks.com/matlabcentral/fileexchange/9700 MATLAB: Change from 1 to -1 Do you mean iteratively in a loop? E.g., changing elements one at a time in column order:n = numel(A);for k=1:n A(k) = -1; % Use A hereend Related QuestionGeneration of random numbersFlipping the numbers 1 to -1What is the difference between mvnrnd and normrndCan I not see Answers after receiving emails from The Mathworks
Best Answer