行列の大きさをそろえる

48 views (last 30 days)
Keito Endo
Keito Endo on 3 Oct 2021
Answered: Keito Endo on 4 Oct 2021
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]、、、

Accepted Answer

Keito Endo
Keito Endo on 4 Oct 2021
ありがとうございます。
解決できました。

More Answers (1)

Toru Ikegami
Toru Ikegami on 3 Oct 2021
こんにちは,元の行列のサイズは全て1行n列(n < 10)だと仮定しての解決策になりますが,
A = [ 3 2 3]
A = 1×3
3 2 3
B = [ 6 9 4 1 4]
B = 1×5
6 9 4 1 4
に対して,
A(end+1:10) = 0
A = 1×10
3 2 3 0 0 0 0 0 0 0
B(end+1:10) = 0
B = 1×10
6 9 4 1 4 0 0 0 0 0
でそれぞれ1行10列の行列になります.(空いている要素は0で補っています)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!