MATLAB: How to find the sum of the perimeter of a matrix matrixperimetersum Hi, I am wondering if I had a matrix [1,2,3;1,2,3;1,2,3] how I could find the sum of the perimeter. Thanks an advance. Best Answer One way amongst any number...>> M=[1,2,3;1,2,3;1,2,3];>> I=ones(size(M)); I(2:end-1,2:end-1)=0;>> S=sum(reshape(M.*I,1,[]))S = 16>> Related SolutionsMATLAB: Finding the sum across the columns in a matrix a=[1 2;3 4]s=sum(a,2) MATLAB: How to sum columns of multiple matrices final_sum=0;for i= 1:32 % splitted command as string: sum(VarNamei) final_sum=final_sum + evalin('base', ['sum(VarName', num2str(i) ,')']);endthe sum of all vectors (if sum is used on a matrix, the result will be a row vector) ...just tell me if it works, i had no problem using it. Related QuestionSum some values of a column based on an other columnMatrices with customized sums for rows and columnsHow to find cell position in a column based on sum of column.Summing a Matrix, row by row.Sum specific range of column or row
Best Answer