odd number ,even number

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

Respuestas (1)

Atsushi Ueno
Atsushi Ueno el 29 de Abr. de 2021

1 voto

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 comentarios

John D'Errico
John D'Errico el 29 de Abr. de 2021
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 el 29 de Abr. de 2021
i am using this site for my own studies , thanks for your advice .

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Productos

Versión

R2021a

Etiquetas

Preguntada:

el 29 de Abr. de 2021

Comentada:

el 29 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by