I have question about if my input matrix was
| 1 2 3 4 |
| 2 3 4 5 |
| 3 4 5 6 |

how I would get an output matrix


| 0 0 0 0 0 0 |
| 0 1 2 3 4 0 |
| 0 2 3 4 5 0 |
| 0 3 4 5 6 0 |
| 0 0 0 0 0 0 |

WITHOUT using for loop || is it impossible in GNU octave?

second question is, also related the 1. one I have a matrix i.e
| 1 2 3 4 |
| 2 3 4 5 |
| 3 4 5 6 |
and I want to return this matrix

| 8/9 15/9 21/9 16/9 |
| 15/9 27/9 36/9 27/9 |
| 12/9 21/9 27/9 20/9 |

again WITHOUT using for loop Is it possible ? Now I just to get one line code segment to get | 1/9 1/9 1/9 |
| 1/9 1/9 1/9 |
| 1/9 1/9 1/9 |

Here my code :

ones(3)/(sum(sum(ones(3))))

actually it is a question about using 3x3 mean filter (which is I get it by above code)
to manipulate matrix
If you can help I really approciate to u. I am really do not know how to complete it :S

Here is code that trying to use min. iterative solution

filter = ones(3)/(sum(sum(ones(3))))
Image = [1,2,3,4;2,3,4,5;3,4,5,6;]
Output = zeros(rows(Image), columns(Image))
cImage = vertcat(zeros(1, columns(Image)+2),(horzcat(zeros(rows(Image), 1), Image, zeros(rows(Image), 1))), zeros(1, columns(Image)+2))

for i=2:rows(Image)+1
      for j=2:columns(Image)+1
		Output(i-1,j-1)=sum(sum(filter.*cImage(i-1:i+1, j-1:j+1)));
	endfor				
endfor
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.