フィルターのクリア

how can I fix this?

1 回表示 (過去 30 日間)
frwmetric
frwmetric 2013 年 5 月 21 日
here is a code to get the permutation of each rows of a matrix
a=[ 1 2 2
2 2 3];
for ii=1:size(a,1)
q(ii,:,:)=unique(perms(a(ii,:)),'rows');
end
out = reshape(q,[],size(a,2),1)
out =
1 2 2
2 2 3
2 1 2
2 3 2
2 2 1
3 2 2
but if consider this matrix
A=[0,0,0;2,2,1;3,0,0]
it gives an error
??? Assignment has more non-singleton rhs dimensions than non-singleton
subscripts
Why? and how can I fix it?

採用された回答

Matt J
Matt J 2013 年 5 月 21 日
編集済み: Matt J 2013 年 5 月 21 日
One way,
q=cell(size(a,1),1);
for ii=1:size(a,1)
q{ii}=unique(perms(a(ii,:)),'rows');
end
out=cell2mat(q);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by