How to I add zeroes onto a matrix?

1 次查看(过去 30 天)
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);
if length(index) ~= length(Matrix)
padarray(index,[0 1],0,'post')
end

采纳的回答

Ryan
Ryan 2021-9-22
编辑:Ryan 2021-9-22
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
Assuming "Matrix" is your data array to pad...
[~,X] = size(Matrix);
if X < 52500
Matrix = [Matrix,zeros(1,52500-X)]
end

更多回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by