Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はマトリックスを持っています
a = [1 2 3 4 5 6 7 8 9 10 11]
これを 5 つの行に分割し、未設定のブロックの残りを次のようにゼロで埋める必要があります。
transformed = [ 1 2 3 4 5 ; 6 7 8 9 10; 11 0 0 0 0 ]
a最初に、次のように必要な数の要素を持つように拡張できます。
a
a(15) = 0 % Matlab will automatically fill elements 12:14 with 0
それから
transformed = reshape(a,[5,3])'
生産する
ans = 1 2 3 4 5 6 7 8 9 10 11 0 0 0 0