want a rows to split into multiple rows

A=[111111111111111111]
i want to generate A=[111111
111111
111111]
it is (3,6) matrix...I know it can be done easily through semicolon but that i dnt want because that A matrix is the output basically.
i also used reshape command but for that dimension shoud be same. i have taken just for example (3,6).actually the matrix is of (1,90) .i wangt to make it (3,30)
kindly help

 採用された回答

Jan
Jan 2022 年 2 月 24 日
編集済み: Jan 2022 年 2 月 24 日

0 投票

X = ones(1, 90);
Y = reshape(X, 3, []); % 2nd argument is determined automatically
% The long form:
Y = reshape(X, 3, numel(X) / 3);

6 件のコメント

Walter Roberson
Walter Roberson 2022 年 2 月 24 日
I have the suspicion that they need
Y = reshape(X, [], 3).'
That is, I suspect that they want row-wise answers, first 30 into the first row, second 30 into the second row, and so on.
VASUNDHARA V
VASUNDHARA V 2022 年 2 月 24 日
ya i want first 30 in first row ,second 30 in second row ,third 30 in third row
Jan
Jan 2022 年 2 月 24 日
編集済み: Jan 2022 年 2 月 24 日
Y = reshape(X, 30, 3).'
A shorter example:
X = 1:12;
Y = reshape(X, [], 3).'
Y = 3×4
1 2 3 4 5 6 7 8 9 10 11 12
VASUNDHARA V
VASUNDHARA V 2022 年 2 月 24 日
ok thankyou all
Jan
Jan 2022 年 2 月 24 日
@VASUNDHARA V: A hint for future questions: You see, that 1:12 is a better example to demonstrate, what you want to achieve than "A=[111111111111111111]". Note that this is not even a vector, but a huge scalar.
VASUNDHARA V
VASUNDHARA V 2022 年 2 月 25 日
thankyou sir

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

その他の回答 (1 件)

DGM
DGM 2022 年 2 月 24 日

0 投票

I don't see why reshape() wouldn't work
A = ones(1,90);
A = reshape(A,3,30)
A = 3×30
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2022 年 2 月 24 日

コメント済み:

2022 年 2 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by