odd number ,even number

4 次查看(过去 30 天)
Hamada Alkhlif
Hamada Alkhlif 2021-4-29
i need acode which detects the odd numbers in the row vector containing the digits of number (1 8 0 5 0 5 7 5 9 )in order and converts odd numbers to even numbers and displays the modified output vector

回答(1 个)

Atsushi Ueno
Atsushi Ueno 2021-4-29
This example below converts odd numbers to even numbers by adding one.
x = [1 8 0 5 0 5 7 5 9]
x = x + mod(x, 2)
x =
1 8 0 5 0 5 7 5 9
x =
2 8 0 6 0 6 8 6 10
  2 个评论
John D'Errico
John D'Errico 2021-4-29
Please don't do student homework assignments for them. It does not help them. It only teaches them this site is here to do thier homework for them.
Hamada Alkhlif
Hamada Alkhlif 2021-4-29
i am using this site for my own studies , thanks for your advice .

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by