How to assign numbers
Mostra commenti meno recenti
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 Commenti
madhan ravi
il 6 Ago 2019
You say you have a highest number , do you mean a threshold value?
karishma koshy
il 6 Ago 2019
madhan ravi
il 6 Ago 2019
a=[1 2 3 0 4 5 0];
a(~a) = max(a)+(1:nnz(~a))
Guillaume
il 6 Ago 2019
@madhan,can you write that as an answer? I don't think it can be done any simpler.
madhan ravi
il 6 Ago 2019
@Guillaume: Done :)
Risposta accettata
Più risposte (1)
Joel Handy
il 6 Ago 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 Commento
karishma koshy
il 6 Ago 2019
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!