Sorting content of table columns
5 ビュー (過去 30 日間)
古いコメントを表示
Isaac Osei Agyemang
2018 年 10 月 8 日
コメント済み: Isaac Osei Agyemang
2018 年 10 月 9 日
Hello Community, please I've a table consisting of numbers, I want to sort column 2 in any order(ascending or decending). I've attached a picture of my table to this question.
2 件のコメント
Guillaume
2018 年 10 月 8 日
Please do not ask the same question multiple time. It's a waste of our effort.
採用された回答
ANKUR KUMAR
2018 年 10 月 8 日
I am giving an example to explain.
clc
clear
load patients
T = table(Gender,Age,Height,Weight,Smoker,Systolic,Diastolic);
If you wish to sort Age out of table, then use
sort(T.Age,'ascend');
Attach you .mat file to get more clarification.
8 件のコメント
Guillaume
2018 年 10 月 8 日
編集済み: Guillaume
2018 年 10 月 8 日
it works fine
It may appear that it does and it may give you the correct result under some circumstances. In the majority of cases, it will give a completely wrong result because sort is the wrong function to use as it will sort each column separately.
I gave you the correct solution in your other identical question, b.t.w. You should read the comments to the question there as well. Until you learn to work properly with graphs, you will run into this sort of problems.
その他の回答 (1 件)
参考
カテゴリ
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!