フィルターのクリア

logical operation on matrix

1 回表示 (過去 30 日間)
Faisal Al-Wazir
Faisal Al-Wazir 2022 年 3 月 8 日
編集済み: Arif Hoq 2022 年 3 月 8 日
Update matrix A so that all odd values will be subtracted by 1
A=[1 2 3;4 5 6; 4 5 2]
A = 3×3
1 2 3 4 5 6 4 5 2
rem(A,2)-1%WRONG
ans = 3×3
0 -1 0 -1 0 -1 -1 0 -1

採用された回答

Arif Hoq
Arif Hoq 2022 年 3 月 8 日
編集済み: Arif Hoq 2022 年 3 月 8 日
A=[1 2 3;4 5 6; 4 5 2]
A = 3×3
1 2 3 4 5 6 4 5 2
B=rem(A,2) % returns the odd number
B = 3×3
1 0 1 0 1 0 0 1 0
output=A-B
output = 3×3
0 2 2 4 4 6 4 4 2

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by