MATLAB: Compute average of each value in a matrix without using for filterfor loopMATLABmatrix manipulation Hi all, I was wondering is it possible to alter each value of a matrix based on the average value of its neighbors, wihtout using for loops? Thanks in advance. Best Answer you can use conv2 or imfilter, for examplex = magic(3)y = conv2(ones(3)/9,x) Related SolutionsMATLAB: Generate a diagonal matrix from the elements of another matrix I would recommend using diag function.The following is an example:A = [1 2 3 4 5; 6 7 8 9 10];A = A';output = diag(A(:));>> outputoutput = 1 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 10 MATLAB: 3D matrix summation For any one of them,sum(T, 3) Related QuestionEasier method to iterative matrix multiplicationHow to randomly generate 0.1 or -0.1Do I get an error when setting the LineStyle property for multiple lines in MATLAB 7.4 (R2007a)How to obtain the coordinates of the mouse on the screen displayed somewhere in the figure window
Best Answer