Reshape a vector to a matrix

41 ビュー (過去 30 日間)
Nicolas Guerrero Naranjo
Nicolas Guerrero Naranjo 2021 年 8 月 18 日
コメント済み: darova 2021 年 8 月 21 日
Hello, I have the following doubt imagining that I have the vector
x=[1 2 3 4 5 6 7 8 9 10]
how can I do to reorganize it as follows
A=[1 2 3 4 5
6 7 8 9 10]
Since as we know reshape organizes as follows.
A=[1 3 5 7 9
2 4 6 8 10]
Thank u so much in advance.
  1 件のコメント
Star Strider
Star Strider 2021 年 8 月 18 日
This seems to be homework.
In any event, just use the reshape function.
.

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

採用された回答

Wan Ji
Wan Ji 2021 年 8 月 18 日
編集済み: Wan Ji 2021 年 8 月 18 日
Just use reshape and transpose it!
x=[1 2 3 4 5 6 7 8 9 10] ;
A = reshape(x, 5, 2)'
Then we get
A =
1 2 3 4 5
6 7 8 9 10
This skill will usually be used in practical matlab programming
  5 件のコメント
Wan Ji
Wan Ji 2021 年 8 月 21 日
thsnk you, darova!
darova
darova 2021 年 8 月 21 日
my pleasure

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by