Interconnecting different sized matrices

6 ビュー (過去 30 日間)
Alonso Figueroa
Alonso Figueroa 2022 年 5 月 5 日
編集済み: dpb 2022 年 5 月 6 日
Hello, I am trying to concatenate two different sizedmatrices into a single one, but in adifferent way that I have been able with reshape() or ndgrid()
My first matrix is as follows:
bob = [x0, y0, z0, i0, j0, k0;
x1, y01 z1, i1, j1, k1]
[x0, y0, z0, i0, j0, k0]
[x1, y01 z1, i1, j1, k1]
and my second matrix: anne: [a0, b0; a1, b1]
[a0, b0]
[a1, b1]
My final result needs to be a matrix with each
[x0, y0, z0, a0, i0, j0, k0, b0]
[x1, y1, z1, a1, i1, j1, k1, b1]
Any idea how i could do this efficiently and without having to manually define each item of the new matrix?
Thank you
  1 件のコメント
Dyuman Joshi
Dyuman Joshi 2022 年 5 月 5 日
The simplest appraoch is - [bob(:,1:3) anne(:,1) bob(:,4:6) anne(:,2)]
if it is just these matrices or another with similar size.

サインインしてコメントする。

採用された回答

dpb
dpb 2022 年 5 月 5 日
編集済み: dpb 2022 年 5 月 6 日
Similar to above but to illustrate vector addressing would be
c=[bob anne];
c=c(:,1:[3 end-1 4:6 end]);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by