Borrar filtros
Borrar filtros

How to replace value with zero to match the size of array

1 visualización (últimos 30 días)
Med Future
Med Future el 1 de Mzo. de 2022
Respondida: KSSV el 1 de Mzo. de 2022
Hello everyone, I hope you are doing well.
I have the dataset which is shape of 250x1000, i want to get only first 20 values from each row and replace all other value with zero
how can i do that in matlab

Respuesta aceptada

KSSV
KSSV el 1 de Mzo. de 2022
Let A be your 250x1000 array.
B = zeros(size(A)) ; % initialize the zero matrix
B(:,1:20) = A(:,1:20) ; % replace first twenty values from each row

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by