필터 지우기
필터 지우기

Sorting content of table columns

조회 수: 5 (최근 30일)
Isaac Osei Agyemang
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
Guillaume 2018년 10월 8일
Please do not ask the same question multiple time. It's a waste of our effort.
Isaac Osei Agyemang
Isaac Osei Agyemang 2018년 10월 9일
My mistake, sorry, thought the first post didn't get through. My apologies.

댓글을 달려면 로그인하십시오.

채택된 답변

ANKUR KUMAR
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
Isaac Osei Agyemang
Isaac Osei Agyemang 2018년 10월 8일
편집: Isaac Osei Agyemang 2018년 10월 8일
Thanks, I've finally been able to do it using your codes.
AA = sort(graphs{1,1}.Edges.EndNode)
graphs{1,1}.Edges.EndNode = AA.
it works fine, Thank You very much.
Guillaume
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개)

KSSV
KSSV 2018년 10월 8일
Read about sort
  댓글 수: 1
Isaac Osei Agyemang
Isaac Osei Agyemang 2018년 10월 8일
I've read about sort, sortrow, sortcols but I'm still having problems with what i want to do.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by