Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
Med Future
Med Future am 1 Mär. 2022
Beantwortet: KSSV am 1 Mär. 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

Akzeptierte Antwort

KSSV
KSSV am 1 Mär. 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

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by