行列の大きさをそろえる
46 views (last 30 days)
Show older comments
A = [5 2 3]
B = [6 9 4 1 4]、、
と様々な大きさの行列が数十種類あります。これらの行列を1行10列の行列に揃えたいです。
大きくした分は0などで補えれば良いかなと思っているのですが何か解決策有りますでしょうか。
例
A = [5 2 3 0 0 0 0 0 0 0]
B = [6 9 4 1 4 0 0 0 0 0]、、、
0 Comments
Accepted Answer
More Answers (1)
Toru Ikegami
on 3 Oct 2021
こんにちは,元の行列のサイズは全て1行n列(n < 10)だと仮定しての解決策になりますが,
A = [ 3 2 3]
B = [ 6 9 4 1 4]
に対して,
A(end+1:10) = 0
B(end+1:10) = 0
でそれぞれ1行10列の行列になります.(空いている要素は0で補っています)
0 Comments
See Also
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!