Info

此问题已关闭。 请重新打开它进行编辑或回答。

how can i split a column and create a new one??

1 次查看(过去 30 天)
suppose A is the column A= 1 2 3 4 4 4 4 3 3 3 2 2 1 and i want m= 1 1; n= 2 2 2; o= 3 3 3 3; p= 4 4 4 4 ;
can anyone tell me this???

回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2015-3-1
A=[ 1 2 3 4 4 4 4 3 3 3 2 2 1]
[B,ii,jj]=unique(A)
out=accumarray(jj,1:numel(jj),[],@(x) {A(x)})
celldisp(out)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by