How to collect it by using loop
4 views (last 30 days)
Show older comments
SYED AQEEL HAIDER
on 4 Dec 2018
Commented: SYED AQEEL HAIDER
on 4 Dec 2018
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 Comments
Stephen23
on 4 Dec 2018
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.
Accepted Answer
madhan ravi
on 4 Dec 2018
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 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!