clc
clear all
n=3; % Three column
j=1;
for ii=1:n
C{ii}=cell(20,1) % Each column got 20 rows.
end
for k=1:2
for l=1:3
for m=1:2
X{j}='No strings attched'; % stored all generated data.
j=j+1;
% I would like to know which column I should store the data.
%Randomly picking a column number
r=ceil(rand(1,1)*n)
% Storing in that column.
***C{r}='No strings attched';***
end
end
end
I've generated three columns and 20 rows. Within a nested loop, I generates a data and stored all of them. Next, I'm picking up a clum randomly and storing the data generated. However, I can see total number of generated data is 12. Which should in columns 1,2,1,3,1,*2,1*,2,3,1,2,1. Hence when I check C(1), it should show six data. But, I couldn't figure out how to do that. Any help appreciated.