How to add zeros to the end of a cell of array

4 views (last 30 days)
plz help
I have two arrays like A={'ATG' 'TCG' 'ATC' 'TTC' 'ACC' 'CCC' 'ACC' 'AAC' 'CAG' 'ACC'}; & B= {'T' '0' '0' 'G' 'G'};
In 'A', I have 10 elements(say m) and in 'B', I have 5(say n) elements. I need to add 10-5=5 (m-n) zeros to the end of B.
I used this
B{numel(A)} = '0'
but the result is 'T' '0' '0' 'G' 'G' [] [] [] [] '0'
i wanna the result 'T' '0' '0' 'G' 'G' '0' '0' '0' '0' '0'

Accepted Answer

Voss
Voss on 16 Sep 2021
B(end+1:numel(A)) = {'0'};

More Answers (0)

Community Treasure Hunt

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

Start Hunting!