1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ある条件で行列の要素の値を変更する。

Posted at

ある条件をもとに行列内の値を変更する。

A = np.array([[1,2,3,4],[-1,2,-9,10],[7,6,10,-8]])

print(A)
# [[ 1  2  3  4]
# [-1  2 -9 10]
# [ 7  6 10 -8]]


# 行列の要素が0以下の場合0にする
A[A <= 0] = 0

print(A)
# [[ 1  2  3  4]
# [ 0  2  0 10]
# [ 7  6 10  0]]
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?