I need help in splitting an array

조회 수: 1 (최근 30일)
Sikder Meaghi
Sikder Meaghi 2021년 1월 26일
댓글: Walter Roberson 2021년 1월 28일
The array I have-
A=[ 2 3 , 4 5 , 8 12 , 5 6 ]
The output I need-
C= [ 2 3 , 4 5 ]
D= [ 8 12 , 5 6 ]
  댓글 수: 6
Sikder Meaghi
Sikder Meaghi 2021년 1월 28일
Thank you very much for the solution. I already found a different approach to it but i shall definately try this too
Walter Roberson
Walter Roberson 2021년 1월 28일
If only there were some way for people who post questions to be more specific about what they want to do...

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2021년 1월 26일
The following code is only valid for A up to 96 entries, after which it will run out of single-character variable names to assign the rows of 4 values into.
A=[ 2 3 , 4 5 , 8 12 , 5 6 ]
A = 1×8
2 3 4 5 8 12 5 6
whos
Name Size Bytes Class Attributes A 1x8 64 double
q7ta90 = buffer(A,4);
for ilil1li = 1 : size(q7ta90, 2)
eval( char([66+ilil1li,61,mat2str(q7ta90(:,ilil1li)),46,39,59]) )
end
clear q7ta90 ilil1li
whos
Name Size Bytes Class Attributes A 1x8 64 double C 1x4 32 double D 1x4 32 double
C
C = 1×4
2 3 4 5
D
D = 1×4
8 12 5 6
Do you need the commas as part of the output? If so then the output cannot be numeric.
  댓글 수: 1
Sikder Meaghi
Sikder Meaghi 2021년 1월 28일
Thank you very much for the solution. I already found a different approach to it but i shall definately try this too

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by