zero padding column of data

How do I extend an existing matrix (200x1 double) with a specific number of zeros? i.e. pad the end of the column

回答 (3 件)

Perry Robertson
Perry Robertson 2015 年 7 月 24 日

1 投票

Solution with calculation of zeros to add:
v = rand(200, 1); % original
finalSize = 400; % the size needed
Nz = finalSize - numel(v); % number zeros needed
v = [v; zeros(Nz,1)]; % vector with zero padding
James Tursa
James Tursa 2015 年 7 月 24 日

0 投票

n = number of elements to pad with 0's
x = your 200 x 1 double array
x(end+1:end+n) = 0;
Star Strider
Star Strider 2015 年 7 月 24 日

0 投票

Probably the easiest way:
v = rand(200, 1); % Original Vector
Nz = 10; % Number Of Zeros To Pad
v = [v; zeros(Nz,1)]; % Zero-Padded Vector

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2015 年 7 月 24 日

回答済み:

2015 年 7 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by