Labeling the columns in an array

81 views (last 30 days)
FW on 12 Jul 2019
Commented: Peter Jarosi on 12 Jul 2019
If we import a .csv or Excel file using readtable, and then convert the table to an array as the following:
We get an output like the following. This syntax process removed all the original labels of each column. Is it possible to label the columns, such as Serial number, Time, Signal 1, Signal 2?
Although one can read and separately isolate the columns, does Matlab allow retaining the labels? Thanks
  1 Comment
John Doe
John Doe on 12 Jul 2019
Unless you are doing an operation that does not support table data sets, leave your data as a table.
Alternatively, save all your variables to cell array using:
varNames = t.Properties.VariableNames;
Then when you want to output your data can recreate the table afterwards.
Don't split your data in to individual variables.

Sign in to comment.

Accepted Answer

Peter Jarosi
Peter Jarosi on 12 Jul 2019
Edited: Peter Jarosi on 12 Jul 2019
Do not convert your table into an array! Just use table object!
Later, if you want to refer it as a matrix you can use the following syntax:
If you want to refer your columns as column vectors use:
Data{:,{'Serial number'}}
If you want your signals in a n by two matrix:
Data{:,{'Signal 1','Signal 2'}}
Peter Jarosi
Peter Jarosi on 12 Jul 2019
You're welcome!
You can still use your data in a table format, just change your 3rd line to:
Signal1=Data{1:382, {'Signal 1'}}; % data in column in 3

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!

Translated by