フィルターのクリア

NxA array and Nx1 array into Nx(A+1) table

3 ビュー (過去 30 日間)
Louis
Louis 2023 年 2 月 8 日
コメント済み: Louis 2023 年 2 月 8 日
I have a variable x that is NxA and a variable y that is Nx1.
I just want to have a table that is Nx(A+1) that is essentially x and y concatenated horizontally.
When I do
table(x, y)
Instead of Nx(A+1) table, I get Nx2 table.
This seems simple, but somehow I can't work the table to do this properly.
Any help would be appreciated.
  1 件のコメント
Stephen23
Stephen23 2023 年 2 月 8 日
"I just want to have a table that is Nx(A+1) that is essentially x and y concatenated horizontally."
Then concatenate x and y horizontally:

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

採用された回答

Tushar Behera
Tushar Behera 2023 年 2 月 8 日
編集済み: Tushar Behera 2023 年 2 月 8 日
Hi Louis,
I believe you want to concatenate two matrices of size NxA and Nx1 and create a matrix of size Nx(A+1).
This can be done by using the "[]" operator. For example:
A=zeros(3,4);
b=ones(3,1)
new=[A b];
newtable=array2table(new)
%%%
newtable =
3×5 table
new1 new2 new3 new4 new5
____ ____ ____ ____ ____
0 0 0 0 1
0 0 0 0 1
0 0 0 0 1
I hope this solves your question.
Regards,
Tushar
  1 件のコメント
Louis
Louis 2023 年 2 月 8 日
Thank you!

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by