To Stupid for Matrix Loop

2 views (last 30 days)
Maike-Sophie Mittelstädt
Maike-Sophie Mittelstädt on 11 Apr 2019
Hello I am Looking for a Loop, but i am not able to find the right one, this is the code i have so far:
function Copy = myfilter(IMG,x,y)
n=pixfilter(IMG,440,280)
IMG(440,280)=n;
n=pixfilter(IMG,440,281)
IMG(440,281)=n;
n=pixfilter(IMG,440,282)
IMG(440,282)=n;
n=pixfilter(IMG,440,283)
IMG(440,283)=n;
n=pixfilter(IMG,440,284)
IMG(440,284)=n;
n=pixfilter(IMG,440,285)
IMG(440,285)=n;
n=pixfilter(IMG,441,280)
IMG(441,280)=n;
n=pixfilter(IMG,441,281)
IMG(441,281)=n;
n=pixfilter(IMG,441,282)
IMG(441,282)=n;
n=pixfilter(IMG,441,283)
IMG(441,283)=n;
n=pixfilter(IMG,441,284)
IMG(441,284)=n;
n=pixfilter(IMG,441,285)
IMG(441,285)=n;
n=pixfilter(IMG,442,280)
IMG(442,280)=n;
n=pixfilter(IMG,442,281)
IMG(442,281)=n;
n=pixfilter(IMG,442,282)
IMG(442,282)=n;
n=pixfilter(IMG,442,283)
IMG(442,283)=n;
n=pixfilter(IMG,442,284)
IMG(442,284)=n;
n=pixfilter(IMG,442,285)
IMG(442,285)=n;
n=pixfilter(IMG,443,280)
IMG(443,280)=n;
n=pixfilter(IMG,443,281)
IMG(443,281)=n;
n=pixfilter(IMG,443,282)
IMG(443,282)=n;
n=pixfilter(IMG,443,283)
IMG(443,283)=n;
n=pixfilter(IMG,443,284)
IMG(443,284)=n;
n=pixfilter(IMG,443,285)
IMG(443,285)=n;
n=pixfilter(IMG,444,280)
IMG(444,280)=n;
n=pixfilter(IMG,444,281)
IMG(444,281)=n;
n=pixfilter(IMG,444,282)
IMG(444,282)=n;
n=pixfilter(IMG,444,283)
IMG(444,283)=n;
n=pixfilter(IMG,444,284)
IMG(444,284)=n;
n=pixfilter(IMG,444,285)
IMG(444,285)=n;
n=pixfilter(IMG,445,280)
IMG(445,280)=n;
n=pixfilter(IMG,445,281)
IMG(445,281)=n;
n=pixfilter(IMG,445,282)
IMG(445,282)=n;
n=pixfilter(IMG,445,283)
IMG(445,283)=n;
n=pixfilter(IMG,445,284)
IMG(445,284)=n;
n=pixfilter(IMG,445,285)
IMG(445,285)=n;
Copy=IMG
end
It is working corrctly but there must be a possible for a nice, elegant Loop. But i Never worked with This Kind of Function in Part of a Mtrix Before:
In The Skript it will be integrated like this:
C=myfilter(IMG,440:445,280:285);

Answers (2)

James Tursa
James Tursa on 11 Apr 2019
Do you mean simply this?
for i=x
for j=y
IMG(i,j) = pixfilter(IMG,i,j);
end
end

Maike-Sophie Mittelstädt
Maike-Sophie Mittelstädt on 11 Apr 2019
Jap, I think this solves my Problem.
Thanks

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!