フィルターのクリア

assigning array to another

2 ビュー (過去 30 日間)
Adem Furkan Mursalli
Adem Furkan Mursalli 2022 年 11 月 5 日
編集済み: Jan 2022 年 11 月 5 日
A= [2, 4, 7, 12, 56, 34, 6, 96, 11, 26] I want to throw an array of 10 numbers into 1 different cell in subgroups of 4 numbers. When we group 4 numbers from a total of 10 numbers, there are 2 groups of 2 remaining numbers. I want to group the remaining 2 numbers with the numbers at the beginning of the array. Can you help?
  3 件のコメント
Image Analyst
Image Analyst 2022 年 11 月 5 日
Huh? Did the poster totally change the question so that the answer is no longer meaningfull?
Jan
Jan 2022 年 11 月 5 日
編集済み: Jan 2022 年 11 月 5 日
@Adem Furkan Mursalli: After I have spent the time for posting an answer, you have removed essential parts of the question and your comment. Now my answer in meaningless and the effort os wasted for the community. Therefore I consider your behavior as impolite. This is not a fair way to participate in a public forum, but annoying.
I more persons act like you did here, nobody would like to spent time for helping others anymore.
The text of the original question was (just for the case, that you want to delete it again):
A= [2, 4, 7, 12, 56, 34, 6, 96, 11, 26] I want to throw an array of 10 numbers into 1 different cell in subgroups of 4 numbers. When we group 4 numbers from a total of 10 numbers, there are 2 groups of 2 remaining numbers. I want to group the remaining 2 numbers with the numbers at the beginning of the array. Can you help?
And your comment to my question for clarification:
cell1={2 4 7 12}, cell2={56 34 6 96}, cell3={11 26 2 4}, cell4={7 12 56 34}, cell5={6 96 11 26}, cell6={2 4 7 12}

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

回答 (1 件)

Jan
Jan 2022 年 11 月 5 日
Maybe:
A = [2, 4, 7, 12, 56, 34, 6, 96, 11, 26];
q = mod((1:24) - 1, numel(A)) + 1;
B = A(q);
B = reshape(B, 4, [])
B = 4×6
2 56 11 7 6 2 4 34 26 12 96 4 7 6 2 56 11 7 12 96 4 34 26 12
Here the wanted subgroups are the columns of B. If you want cells:
C = num2cell(B.', 2)
C = 6×1 cell array
{[ 2 4 7 12]} {[56 34 6 96]} {[ 11 26 2 4]} {[7 12 56 34]} {[6 96 11 26]} {[ 2 4 7 12]}

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by