Filter löschen
Filter löschen

Sorting content of table columns

5 Ansichten (letzte 30 Tage)
Isaac Osei Agyemang
Isaac Osei Agyemang am 8 Okt. 2018
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 Kommentare
Guillaume
Guillaume am 8 Okt. 2018
Please do not ask the same question multiple time. It's a waste of our effort.
Isaac Osei Agyemang
Isaac Osei Agyemang am 9 Okt. 2018
My mistake, sorry, thought the first post didn't get through. My apologies.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

ANKUR KUMAR
ANKUR KUMAR am 8 Okt. 2018
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 Kommentare
Isaac Osei Agyemang
Isaac Osei Agyemang am 8 Okt. 2018
Bearbeitet: Isaac Osei Agyemang am 8 Okt. 2018
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 am 8 Okt. 2018
Bearbeitet: Guillaume am 8 Okt. 2018
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

KSSV
KSSV am 8 Okt. 2018
Read about sort
  1 Kommentar
Isaac Osei Agyemang
Isaac Osei Agyemang am 8 Okt. 2018
I've read about sort, sortrow, sortcols but I'm still having problems with what i want to do.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by