How do you set entries in a matrix for odd rows with odd columns to zero?

 Respuesta aceptada

%random data for example
A = rand(6,7)
A = 6×7
0.5610 0.2871 0.6280 0.3569 0.2765 0.5197 0.9541 0.3110 0.6573 0.3447 0.8105 0.0255 0.8263 0.2238 0.1450 0.6944 0.2345 0.6517 0.8826 0.6646 0.2389 0.0189 0.9227 0.6658 0.1392 0.9954 0.4346 0.1812 0.2084 0.3130 0.1589 0.8685 0.6272 0.6153 0.3176 0.9900 0.3501 0.1301 0.0931 0.5342 0.8533 0.5644
A(1:2:end,1:2:end)=0
A = 6×7
0 0.2871 0 0.3569 0 0.5197 0 0.3110 0.6573 0.3447 0.8105 0.0255 0.8263 0.2238 0 0.6944 0 0.6517 0 0.6646 0 0.0189 0.9227 0.6658 0.1392 0.9954 0.4346 0.1812 0 0.3130 0 0.8685 0 0.6153 0 0.9900 0.3501 0.1301 0.0931 0.5342 0.8533 0.5644

Más respuestas (0)

Categorías

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

Productos

Versión

R2021b

Preguntada:

el 15 de Feb. de 2023

Respondida:

el 15 de Feb. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by