# How to assign numbers

1 view (last 30 days)
karishma koshy on 6 Aug 2019
Commented: karishma koshy on 6 Aug 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 CommentsShow 3 older commentsHide 3 older comments
Guillaume on 6 Aug 2019
@madhan,can you write that as an answer? I don't think it can be done any simpler.
madhan ravi on 6 Aug 2019
@Guillaume: Done :)

Sign in to comment.

### Accepted Answer

madhan ravi on 6 Aug 2019
a = [1 2 3 0 4 5 0];
a(~a) = max(a) + (1:nnz(~a))
##### 1 CommentShow -1 older commentsHide -1 older comments
karishma koshy on 6 Aug 2019
Thank you sir

Sign in to comment.

### More Answers (1)

Joel Handy on 6 Aug 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 CommentShow -1 older commentsHide -1 older comments
karishma koshy on 6 Aug 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

Sign in to comment.

### Categories

Find more on Logical in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!