<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Le 14/01/2020 à 22:40, Federico Miyara
a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:97d5ab0a-65ed-132a-4a47-294ceba3274f@fceia.unr.edu.ar">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<font face="Courier New"><br>
Dear all,<br>
<br>
I need to zero-pad the columns of an N-D array x to a length N.
I've found the following solution: <br>
<br>
siz = size(x);<br>
a = repmat(0,[N, siz(2:$)]); // Create array of 0's whose
columns have length N<br>
// and the remaining dimensions
are the same as in x<br>
a(1:siz(1), :) = x; // Replace non-padding 0's by
x <br>
<br>
</font><br>
<font face="Courier New"><font face="Courier New">This seems to
work. </font></font></blockquote>
<p>Really?:</p>
<p><tt>--> x = rand(3,4,2);</tt><tt><br>
</tt><tt>--> N= 5;</tt><tt><br>
</tt><tt>--> siz = size(x);</tt><tt><br>
</tt><tt>--> a = repmat(0,[N, siz(2:$)]); // Create array
of 0's whose columns have length N</tt><tt><br>
</tt><tt>--> a(1:siz(1), :) = x</tt><tt><br>
</tt><tt><br>
</tt><font color="#ff6666"><tt>Submatrix incorrectly defined.</tt></font><tt><br>
</tt><br>
</p>
<p>Why not using resize_matrix()?</p>
<p><font size="-1" face="Courier New">s = size(a);<br>
x = resize_matrix(x,</font><font size="-1" face="Courier New"><font
face="Courier New">[N, s(2:$)]);</font></font></p>
<p><font face="Courier New"><font face="Courier New"><font size="-1">-->
resize_matrix(x,[N s(2:$)])<br>
ans =<br>
(:,:,1)<br>
0.3616361 0.4826472 0.5015342 0.6325745<br>
0.2922267 0.3321719 0.4368588 0.4051954<br>
0.5664249 0.5935095 0.2693125 0.9184708<br>
0. 0. 0. 0. <br>
0. 0. 0. 0. <br>
(:,:,2)<br>
0.0437334 0.4148104 0.7783129 0.6856896<br>
0.4818509 0.2806498 0.211903 0.1531217<br>
0.2639556 0.1280058 0.1121355 0.6970851<br>
0. 0. 0. 0. <br>
0. 0. 0. 0. </font><br>
</font></font></p>
<p>Samuel</p>
<p><br>
</p>
</body>
</html>