How to I add zeroes onto a matrix?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Sarah Nolt-Caraway
am 21 Sep. 2021
Beantwortet: Stephen23
am 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);
if length(index) ~= length(Matrix)
padarray(index,[0 1],0,'post')
end
0 Kommentare
Akzeptierte Antwort
Ryan
am 22 Sep. 2021
Bearbeitet: Ryan
am 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
Assuming "Matrix" is your data array to pad...
[~,X] = size(Matrix);
if X < 52500
Matrix = [Matrix,zeros(1,52500-X)]
end
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!