Effacer les filtres
Effacer les filtres

how can i create a matrix in a loop and have some elements changing with every iteration

1 vue (au cours des 30 derniers jours)
I want to create a 10 by 10 matrix in a loop and have some elements changing between a particular range of values for each iteration.
  4 commentaires
Stephen23
Stephen23 le 4 Juil 2018
@Folakemi Omotoye: can you please give an example.
Stephen23
Stephen23 le 4 Juil 2018
Folakemi Omotoye's "Answer" moved here:
n=9;
for k=1:n
m{k}=1*k+ones(10)% to create 10 by 10 matrix
disp(m{k}) % to display matrix outcome for kth iteration
end
i need to include a line to change the values of some of the pixels. I do not know how to do that.

Connectez-vous pour commenter.

Réponse acceptée

Stephen23
Stephen23 le 4 Juil 2018
n = 9;
c = cell(1,n);
for k=1:n
c{k} = 1*k+ones(10);
c{k}(5,:) = 0 % change the fifth row's values.
end
  2 commentaires
Stephen23
Stephen23 le 4 Juil 2018
@Folakemi Omotoye: I hope that it helped. Remember to accept the answer that helped you most: accepting answers is an easy way of showing your appreciation of the volunteers who help on this forum.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical 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!

Translated by