how to multiply a number in even rows of matrix?

1 visualización (últimos 30 días)
leeee
leeee el 21 de Oct. de 2019
Respondida: Akira Agata el 21 de Oct. de 2019
I have: output2=-1*ones(input1,input4), how do i make all the even columns be 2? Thanks
Task: output2 is an (input1) × input4 matrix where the entries of all the odd columns are all -1 and the entries of all the even columns are all 2’s.

Respuesta aceptada

Akira Agata
Akira Agata el 21 de Oct. de 2019
Please try the following:
output2(:,2:2:end) = 2;

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by