How to I add zeroes onto a matrix?

1 view (last 30 days)
Sarah Nolt-Caraway
Sarah Nolt-Caraway on 21 Sep 2021
Answered: Stephen23 on 22 Sep 2021
So I have a matrix, that needs to be 1x52500. If it isnt, I want to pad zeroes onto the end. This is what I have, but it did not add the zeroes.
Matrix = zeros(1,52500);
iflength(index) ~= length(Matrix)
padarray(index,[0 1],0,'post')
end

Accepted Answer

Ryan
Ryan on 22 Sep 2021
Edited:Ryan on 22 Sep 2021
I don't have the image processing toolbox so not sure how you would do it with padarray but you could also do it this way
假设“矩阵”是您的数据数组来垫. ..
[~,X] = size(Matrix);
ifX < 52500
Matrix = [Matrix,zeros(1,52500-X)]
end

More Answers (1)

Stephen23
Stephen23 on 22 Sep 2021
Where V is your vector:
V(end+1:52500) = 0

下载188bet金宝搏


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by