Saving data for each iteration of a for loop

2 visualizaciones (últimos 30 días)
Jason
Jason el 11 de Feb. de 2013
I am writing a program that generates two random numbers, a random x and y value for a single point, within a for loop. This point correlates to a central value for a 5x5 pixel gaussian spot that is being added to an image. My goal is to place a large amount of these spots, without overlapping, randomly over the image, which I can currently do. However, I would then like to save the central locations of each point so I can use the same central points on another image. Right now to attempt to save the point location within my for loop I am using
A = cell(NumberOfSpots,2);
for n = 1 : 1 : NumberOfSpots;
r1 = randi(ArraySizeX-6,1,1)+3;
r2 = randi(ArraySizeY-6,1,1)+3;
A{n} = [r1,r2];
...(gaussian spot code)
end
disp(A)
which shows
A =
[1x2 double] []
[1x2 double] []
[1x2 double] []
[1x2 double] []
[1x2 double] []
[1x2 double] []
[1x2 double] []
[1x2 double] []
[1x2 double] []
[1x2 double] []
Please help if you have any ideas on how I could fix this problem to show the point instead of 1x2 double. Thank you!

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 11 de Feb. de 2013
Editada: Azzi Abdelmalek el 11 de Feb. de 2013
cell2mat((A)

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by