Populate a column vector with values from another column vector
Afficher commentaires plus anciens
Hey!
I have a column vector A that is 1x50 that contains values
I want to populate a 1x57 zero column vector B with the values of A at a certain index.
E.g. At index 0,1,2,5,7,8,11 should all be 0 - the other values of vector B should be populated from the non-zero values in vector A. How do i go about doing this?
2 commentaires
KSSV
le 5 Déc 2022
How index can be 0? Index cannot be zero. Your question is not clear though.
Raahim Muzaffar
le 5 Déc 2022
Réponse acceptée
Plus de réponses (1)
Voss
le 5 Déc 2022
B = zeros(57,1); % 57x1 column vector
B([4 5 7 10 11 13:end]) = A;
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!