How to assign numbers

7 vues (au cours des 30 derniers jours)
karishma koshy
karishma koshy le 6 Août 2019
Commenté : karishma koshy le 6 Août 2019
Hi all I have got a table where I want to assign number bigger than the highest number already there in the table to the ones assigned zero. How can I do that.
  5 commentaires
Guillaume
Guillaume le 6 Août 2019
@madhan,can you write that as an answer? I don't think it can be done any simpler.
madhan ravi
madhan ravi le 6 Août 2019
@Guillaume: Done :)

Connectez-vous pour commenter.

Réponse acceptée

madhan ravi
madhan ravi le 6 Août 2019
a = [1 2 3 0 4 5 0];
a(~a) = max(a) + (1:nnz(~a))
  1 commentaire
karishma koshy
karishma koshy le 6 Août 2019
Thank you sir

Connectez-vous pour commenter.

Plus de réponses (1)

Joel Handy
Joel Handy le 6 Août 2019
Something like this?
table = randi([0 10],10,10);
tableMax = max(max(table));
table(table==0) = tableMax+1;
% Or Just
table(table==0) = Inf;
  1 commentaire
karishma koshy
karishma koshy le 6 Août 2019
If I am having one of the column with 1 2 3 0 4 5 0 and I want it has 1 2 3 6 4 5 7. How can I do that
Thank you

Connectez-vous pour commenter.

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