Extracting matrix values for an algorithm

1 回表示 (過去 30 日間)
deep Dhillon
deep Dhillon 2019 年 2 月 1 日
回答済み: deep Dhillon 2019 年 2 月 1 日
HEllo Everyone
I have an n*2 array,, The first column represent x values and the second represent y values of certain object coordinates. What i wanna do is to use those values in the array sequentitally to run a specific algorithm of them. SO in essence can someone help in how can i extract the values of the array, such that i extract x1,y1,, run algorith on them and then x2,y2 as such. I have written the alogorithm below and the way i am getting center values is in attached image.. Any suggestion or help is greatly appreciated.
figure, imshow(mush);
hold on
x=centers(1);
y= 199;
plot(centers)
boxHalfWidth = 40; %
boxXStart = x-boxHalfWidth;
boxYStart = y-boxHalfWidth;
boxWidth = 2 * boxHalfWidth;
boxHeight = 2 * boxHalfWidth;
rectangle('Position',[boxXStart boxYStart boxWidth boxHeight])
Regards
Arun

採用された回答

James Tursa
James Tursa 2019 年 2 月 1 日
Something like this?
xy = your n x 2 array
n = size(xy,1);
for k=1:n
% run your algorithm here with x = xy(k,1) and y = xy(k,2)
end

その他の回答 (1 件)

deep Dhillon
deep Dhillon 2019 年 2 月 1 日
James Thanks a lot
It works perfectly

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by