Sortrows_function of a Matrix
1 回表示 (過去 30 日間)
古いコメントを表示
T=[1:10;40,43,18,43,34,18,23,31,44,38]';
T=ShortestTime(T)
T=LongestTime(T)
function [c]=ShortestTime(T)
c=sortrows(T,[2 1])
end
function [c]=LongestTime(T)
c=sortrows(T,[-2 1])
end
Hi, I wrote a little script to sort a matrix. But now I want that Matlab write only the first column of the matrix. How do I do that?
0 件のコメント
回答 (1 件)
Ameer Hamza
2020 年 3 月 14 日
You can get the first column of a matrix by indexing like this
first_column = T(:,1);
2 件のコメント
Ameer Hamza
2020 年 3 月 14 日
I am not sure about your question. Maybe you want to save them in different variables
T=[1:10;40,43,18,43,34,18,23,31,44,38]';
T1=ShortestTime(T);
T2=LongestTime(T);
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!