I want to repeat this code 32 times and each time stores the result to get matrix 1*32
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Osama Dwairi
le 14 Mai 2020
Commenté : Osama Dwairi
le 14 Mai 2020
counter=0;
for i=1:256
for j= 1:256
if L(i,j) == k
counter= counter+1;
end
end
end
0 commentaires
Réponse acceptée
Geoff Hayes
le 14 Mai 2020
Osama - presumably you want to store the counter value from each of the 32 iterations so you could do something like
n = 32;
counter = zeros(n,1);
for m = 1:n
for i=1:256
for j= 1:256
if L(i,j) == k
counter(m) = counter(m) + 1;
end
end
end
end
I'm assuming that there is some missing code since the above will produce the same result (i.e. all elements of counter will be identical) for each of the 32 iterations.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!