how can i change a position of a matrix to 1?

1 回表示 (過去 30 日間)
suchismita
suchismita 2014 年 6 月 30 日
コメント済み: suchismita 2014 年 6 月 30 日
i have a matrix a=rand(1,10). now i want to change 2,4,6 position of matrix to 1.
how can i do that....
plz plz plz help me

採用された回答

Matt J
Matt J 2014 年 6 月 30 日
a([2,4,6])=1
  1 件のコメント
suchismita
suchismita 2014 年 6 月 30 日
thank u....if the positions are random then what will be the code????

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

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2014 年 6 月 30 日
a = rand(10,1);
a(randperm(10,3)) = 1;
  1 件のコメント
suchismita
suchismita 2014 年 6 月 30 日
thank u so much

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

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by