Sorting Columns of a table.

6 次查看(过去 30 天)
Isaac Osei Agyemang
评论: Guillaume 2018-10-8
I have a table with two columns without any title, i want to sort the numbers in the table in an order. I've a ttached a picture of my table to the question.
  5 个评论
Walter Roberson
Walter Roberson 2018-10-8
graph() accepts numeric s and t arrays. categorical too I think.
Guillaume
Guillaume 2018-10-8
Yes, the edges can be numeric (and usually are), the node names cannot be numeric.
However, looking at the discussion in the other identical question, that wx appears to be simply a copy of the Edge table, not something generated from the Node table, so you are right, the values in wx should be numeric.

请先登录,再进行评论。

回答(2 个)

KSSV
KSSV 2018-10-8
Okay you can sort them in the way you want. Have a look on the function sort. With this you can sort.

Guillaume
Guillaume 2018-10-8
编辑:Guillaume 2018-10-8
If you want to sort wx according to the numeric values:
[~, order] = sortrows(str2double(wx.EndNodes));
wx = wx(order, :);

类别

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