Please, Need help on MATLAB!!!!!!!!!
Write a script/function that does the following:
It takes a matrix, of arbitrary size (m x 1, 1 x n, or m x n), and computes an output matrix of identical size.
The i, jth element of the output is equal to the sum of all the surrounding elements of the i, jth element of the input matrix.
For elements on the edge and corner of the input matrix there will be fewer elements to add.
Examples:
[1 0]
> [0 1]
[1 0;
> [1 2;
0 1]
> 2 1]
[0 0 0;
> [1 1 1;
0 1 0;
> 1 0 1;
0 0 0]
> 1 1 1]
It takes a matrix, of arbitrary size (m x 1, 1 x n, or m x n), and computes an output matrix of identical size.
The i, jth element of the output is equal to the sum of all the surrounding elements of the i, jth element of the input matrix.
For elements on the edge and corner of the input matrix there will be fewer elements to add.
Examples:
[1 0]
> [0 1]
[1 0;
> [1 2;
0 1]
> 2 1]
[0 0 0;
> [1 1 1;
0 1 0;
> 1 0 1;
0 0 0]
> 1 1 1]
0
Comments