PDA

View Full Version : Please, Need help on MATLAB!!!!!!!!!


mypeace
16 Oct 2008, 4:24am
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]

shwaip
16 Oct 2008, 6:13am
If I do your homework now, how do you expect to pass tests?