Write A Matlab Function of a matrix
12 ビュー (過去 30 日間)
古いコメントを表示
Write a matlab function which accepts n (row) by m (col) matrix. The function will exclude the repeated elements and sort the rest of the elements in descending order. (You can use any reasonable way to solve this problem).
Can u please help me about this question
4 件のコメント
Rik
2018 年 1 月 14 日
Spam by flag must be the most stupid kind of posting spam. Am I correct in assuming people with the reputation level to remove this flag will see it?
回答 (2 件)
ANKUR KUMAR
2018 年 1 月 14 日
編集済み: ANKUR KUMAR
2018 年 1 月 14 日
A=randi(25,25,100);
ss=func(A,10,20)
function S = func(A,m,n)
B=A(1:m,1:n);
C=B(:);
id=unique(C)
S=sort(id,'descend')
end
2 件のコメント
Jan
2018 年 1 月 14 日
If you are looking for a unique list of elements, start with a search in the documentation:
docsearch unique
You will find a command called unique(). See:
doc unique
Now its input should be a vector, not a matrix. Read the "Getting Started" chapter to learn, what A(:) does. For sorting:
docsearch sort
And again sort() is existing as command already.
doc sort
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Shifting and Sorting Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!