行列の大きさをそろえる

48 Ansichten (letzte 30 Tage)
Keito Endo
Keito Endo am 3 Okt. 2021
Beantwortet: Keito Endo am 4 Okt. 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]、、、

Akzeptierte Antwort

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

Weitere Antworten (1)

Toru Ikegami
Toru Ikegami am 3 Okt. 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で補っています)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!