how can i slove this proplem "- The vector V is given by V=[2 8 7 3 1 0 8 9]. Write down a single instruction to produce a vector that contains 1 in the place of the odd numbers and -1 in the place of the even numbers."
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Reem Hegazy
el 13 de Oct. de 2019
Respondida: Fabio Freschi
el 13 de Oct. de 2019
- The vector V is given by V=[2 8 7 3 1 0 8 9]. Write down a single Matlab instruction to produce a vector that contains 1 in the place of the odd numbers and -1 in the place of the even numbers.
1 comentario
Respuesta aceptada
Fabio Freschi
el 13 de Oct. de 2019
A suggestion: you can easily find the reminder of the division by 2, so that even numers have reminder 0 and odd numbers reminder 1. Now you should map these numbers to -1 and 1, respectively. The problem is that you must write a single instruction, so you can play with algebra: multiply by 2 and subtract 1. From now on it's just a translation of this idea in matlab language
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!