フィルターのクリア

change even column values only

3 ビュー (過去 30 日間)
PK
PK 2016 年 9 月 29 日
コメント済み: Thorsten 2016 年 9 月 29 日
I create 20*20 2D array of all ones. And then I want to change even columns to minus one. How can I change with builtin function?

採用された回答

Thorsten
Thorsten 2016 年 9 月 29 日
A = ones(20);
A(:,mod(1:20, 2) == 0) = -1;
  2 件のコメント
PK
PK 2016 年 9 月 29 日
good answer! I got the following method.... A = ones(20) A(:,2:2:end) = -1
Thorsten
Thorsten 2016 年 9 月 29 日
You method is even better!

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

その他の回答 (1 件)

PK
PK 2016 年 9 月 29 日
good answer! I got the following method.... A = ones(20) A(:,2:2:end) = -1

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by