How to collect it by using loop

4 ビュー (過去 30 日間)
SYED AQEEL HAIDER
SYED AQEEL HAIDER 2018 年 12 月 4 日
コメント済み: SYED AQEEL HAIDER 2018 年 12 月 4 日
In response of statement
[J,K] = find(Image);
I have got J and K of size [14,1]
Now I want to locate
R1 = [J(1), K(1)]
R2 = [J(2), K(2)] and so on till R14 = [J(14), K(14)]
How to complete this task using loop?
  2 件のコメント
Stephen23
Stephen23 2018 年 12 月 4 日
You tagged this question with "changing variable name for each iteration", but it is important to learn that magically changing variable names is one way that beginners force themselves into writing slow, complex, buggy code that is hard to debug. Read this to know why:
The MATLAB documentation and all experienced MATLAB users reccomend using indexing. Indexing is neat, simple, very efficient, and easy to debug. Unlike what you are trying to do.
SYED AQEEL HAIDER
SYED AQEEL HAIDER 2018 年 12 月 4 日
Thanks for guidance.
What may be done for using indexing for solving this?

サインインしてコメントする。

採用された回答

madhan ravi
madhan ravi 2018 年 12 月 4 日
Don't name the variable dynamically use cell instead
R=cell(1,14); % preallocation
for i=1:14
R{i}=find(image);
end
celldisp(R)
  3 件のコメント
madhan ravi
madhan ravi 2018 年 12 月 4 日
size(J,1)
SYED AQEEL HAIDER
SYED AQEEL HAIDER 2018 年 12 月 4 日
I am having these points
R1 = [387, 144]
R2 = [392, 145]
R3 = [400, 147]
R4 = [405, 150]
R5 = [393,152]
R6 = [402, 158]
R7 = [395, 168]
R8 = [381,180]
R9 = [492, 334]
R10 = [293, 354]
R11 = [291, 355]
R12 = [284, 356]
R13 = [288, 356]
R14 = [438, 688]
Now, I have to calculate mean of the neighboring points. There are four clusters of white dots. R1, R2, R3, R4, R5, R6, R7 and R8 in cluster1; R9 in cluster2; 10, R11, R12, R13 in cluster3 and R14 in cluster4. How may I group these points automatically and calculate the mean of culter1 and 3. Kindly mention. I have tried 'kmedoid' but it is not working for me.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by