Creating a new matrix in each iteration
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hey guys,
I am trying to create a new matrix in each iteration.
something like
for i=1:n
somerandommatrix(n)(i,j)=[x,y];
end
anyone know how to do such thing?
Thanks in advance.
3 comentarios
per isakson
el 28 de Jul. de 2012
BTW:
if false
...
...
end
used to be a trick to "comment out" block of code. Now that is better done with
%{
....
....
%}
which Matlab understand and turns the "comments" green. More readable - fewer mistakes.
Respuesta aceptada
per isakson
el 28 de Jul. de 2012
Editada: per isakson
el 28 de Jul. de 2012
Since we don't know the size of coveredrtptest beforehand it is a bit tricky to preallocate it.
This will give you a cell array, somerandommatrix, the elements, coveredrtptest, of which are double arrays.
len = length(possiblebasesite);
somerandommatrix = cell( len, 1 ); % allocate memory
for jj=1:len
coveredrtptest = [];
for ii=1:numberofrtp
if ...
if ...
coveredrtptest(end+1,1:2)=rtpposition(ii,1:2);
end
end
end
somerandommatrix{jj} = coveredrtptest;
end
0 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!