Populate a column vector with values from another column vector
Show older comments
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 Comments
KSSV
on 5 Dec 2022
How index can be 0? Index cannot be zero. Your question is not clear though.
Raahim Muzaffar
on 5 Dec 2022
Accepted Answer
More Answers (1)
Voss
on 5 Dec 2022
B = zeros(57,1); % 57x1 column vector
B([4 5 7 10 11 13:end]) = A;
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!