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 Kommentare

Walter Roberson
Walter Roberson am 8 Okt. 2018
Is there a particular reason why you did not store them as numeric if you want them to act numeric?
I suspect the reason is that graph won't let you use numeric values for the node names.
>> g = graph(eye(3));
>> g.Nodes = table([1;2;3], 'VariableNames', {'Name'})
Error using graph.validateName (line 358)
Node names must be a cell array of nonempty character vectors.
Guillaume
Guillaume am 8 Okt. 2018
And please do not ask the same question multiple times. It's a waste of our effort.
Walter Roberson
Walter Roberson am 8 Okt. 2018
graph() accepts numeric s and t arrays. categorical too I think.
Guillaume
Guillaume am 8 Okt. 2018
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.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

KSSV
KSSV am 8 Okt. 2018

0 Stimmen

Okay you can sort them in the way you want. Have a look on the function sort. With this you can sort.
Guillaume
Guillaume am 8 Okt. 2018
Bearbeitet: Guillaume am 8 Okt. 2018

0 Stimmen

If you want to sort wx according to the numeric values:
[~, order] = sortrows(str2double(wx.EndNodes));
wx = wx(order, :);

Kategorien

Gefragt:

am 8 Okt. 2018

Kommentiert:

am 8 Okt. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by