Creating a new matrix in each iteration
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
per isakson
le 28 Juil 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.
Réponse acceptée
per isakson
le 28 Juil 2012
Modifié(e) : per isakson
le 28 Juil 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 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!