Info
此问题已关闭。 请重新打开它进行编辑或回答。
how can i determine whether a matrix of any size is sorted or not (by rows and by columns)?
1 次查看(过去 30 天)
显示 更早的评论
suppose i have A = [1 2 3 4; 5 6 7 8] is sorted
but A = [1 2 3 4; 5 6 8 7] is not
diff(A) returns "1"-s mtrix if columns are sorted
0 个评论
回答(2 个)
Azzi Abdelmalek
2012-12-6
编辑:Azzi Abdelmalek
2012-12-6
out1=all(arrayfun(@(x) issorted(A(x,:)),1:size(A,1))) % by rows
out2=all(arrayfun(@(x) issorted(A(:,x)),1:size(A,2))) % by columns
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!