MATLAB: Creating a function that has an input from another algorithm

algorithmfunctionimage processingMATLABmatlab functionstatisticsworkflow

HEllo Everone
I am having an algorithm which is giving me an output in the form of a variable (on my workspace). The Variable(centers) is an n*2 array and is giving me center locatations or x,y coordinates of bunch of different circles on an image. What i wanna do is to use that centers variable and create bounding boxes on each of those coordinates. For creating the bounding box on any x,y cordinate, i am using the following algorithm.
figure, imshow(im1)
hold on
x=425.7450;
y= 211.1882;
plot(centers)
boxHalfWidth = 40; %
boxXStart = x-boxHalfWidth;
boxYStart = y-boxHalfWidth;
boxWidth = 2 * boxHalfWidth;
boxHeight = 2 * boxHalfWidth;
rectangle('Position',[boxXStart boxYStart boxWidth boxHeight])
Can anyone please help me, about how do i create a function in which i give the input as centers for each x,y pair and in turn execute the above written algorithm (boundbox) sequentially on each x,y values in that centers array, so that i get bounding boxes on all those x,y pairs.
Please find the attached screenshot of the centers array as well. Any suggestion or help will be greatly appreciated .

Best Answer

Actually i figured out the way to do this from some resources, but thanks a lot for every1's contribution.
Here is how i am able to get it
n = size(centers,1);
figure, imshow(mush);
hold on
for k=1:n
% run your algorithm here with x = xy(k,1) and y = xy(k,2)
x = centers(k,1);
y = centers(k,2);
plot(centers)
boxHalfWidth = 40; %
boxXStart = x-boxHalfWidth;
boxYStart = y-boxHalfWidth;
boxWidth = 2 * boxHalfWidth;
boxHeight = 2 * boxHalfWidth;
rectangle('Position',[boxXStart boxYStart boxWidth boxHeight])
end