How to assign numbers

7 ビュー (過去 30 日間)
karishma koshy
karishma koshy 2019 年 8 月 6 日
コメント済み: karishma koshy 2019 年 8 月 6 日
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 件のコメント
Guillaume
Guillaume 2019 年 8 月 6 日
@madhan,can you write that as an answer? I don't think it can be done any simpler.
madhan ravi
madhan ravi 2019 年 8 月 6 日
@Guillaume: Done :)

サインインしてコメントする。

採用された回答

madhan ravi
madhan ravi 2019 年 8 月 6 日
a = [1 2 3 0 4 5 0];
a(~a) = max(a) + (1:nnz(~a))
  1 件のコメント
karishma koshy
karishma koshy 2019 年 8 月 6 日
Thank you sir

サインインしてコメントする。

その他の回答 (1 件)

Joel Handy
Joel Handy 2019 年 8 月 6 日
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 件のコメント
karishma koshy
karishma koshy 2019 年 8 月 6 日
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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by