I need help in splitting an array
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
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
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 ]
whos
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
C
D
Do you need the commas as part of the output? If so then the output cannot be numeric.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!