Array inside an array

193 ビュー (過去 30 日間)
Sagar Gupta Satrasala
Sagar Gupta Satrasala 2021 年 1 月 24 日
編集済み: Jan 2021 年 1 月 24 日
I have to insert a 3x1 matrix into a another matrix where this 3x1 matrix would be the first element of that matrix. Can anyone please tell me how do i do that?

回答 (2 件)

Jan
Jan 2021 年 1 月 24 日
編集済み: Jan 2021 年 1 月 24 日
The elements of a matrix cannot be a matrix again. But you can insert the elements, such that the array grows:
x = 1:3;
y = 7:9;
insertAt = 1
joined = [x(1:insertAt - 1), y, x(insertAt + 1:end)]
% joined =
% 7 8 9 2 3

Mario Malic
Mario Malic 2021 年 1 月 24 日
Hi,
You can do this with cell arrays
a =cell(3,1);
b = rand(3,1)
b =
0.8147
0.9058
0.1270
a{1} = b
a =
3×1 cell array
{3×1 double}
{0×0 double}
{0×0 double}

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by