MATLAB: How to collect it by using loop

changing variable name for each iteration

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?

Best Answer

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)
Related Question