Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to *programmatically* reorder dataset variables?

Subject: How to *programmatically* reorder dataset variables?

From: kj

Date: 7 Jun, 2013 19:08:09

Message: 1 of 4



How can one reorder the variables (aka "columns") of a dataset
programmatically?

Thanks in advance!

kj

Subject: How to *programmatically* reorder dataset variables?

From: Tom Lane

Date: 7 Jun, 2013 19:18:24

Message: 2 of 4

> How can one reorder the variables (aka "columns") of a dataset
> programmatically?

I would do it by column indexing:

load hospital
h = hospital(1:4,:)
g = h(:,randperm(7))

-- Tom

Subject: How to *programmatically* reorder dataset variables?

From: james bejon

Date: 8 Jun, 2013 06:54:09

Message: 3 of 4

% You can use the column names if you want, e.g.,

ds = ds(:, sort(ds.Properties.VarNames) );

Subject: How to *programmatically* reorder dataset variables?

From: kj

Date: 8 Jun, 2013 12:16:11

Message: 4 of 4


Tom, James: thanks, that did the trick.

kj

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us