How can I pad zeros to each column of a matrix?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Luki
am 27 Dez. 2016
Kommentiert: Image Analyst
am 27 Dez. 2016
I am given a matrix with t rows and n columns. I want to add zeros to each column. How can I achieve this? I was thinking about the padarray-command:
X_padded = padarray(X,[10000 0]);
But I think this yields a matrix X with only zeros added to it in column n=1.
0 Kommentare
Akzeptierte Antwort
Stephen23
am 27 Dez. 2016
Here are two easy ways to add zeros onto a matrix:
>> mat = [1,2,3;4,5,6]
mat =
1 2 3
4 5 6
>> [mat;zeros(2,3)]
ans =
1 2 3
4 5 6
0 0 0
0 0 0
>> mat(5,1) = 0
mat =
1 2 3
4 5 6
0 0 0
0 0 0
0 0 0
2 Kommentare
Image Analyst
am 27 Dez. 2016
Try getting rid of the third dimension, if you don't need or want it, like this:
x = squeeze(x);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multirate Signal Processing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!