how to import date with other variables from the XLX file.

2 visualizaciones (últimos 30 días)
Dear All,
I want to import data with the 875*4 data. The first row represents the name of the variables. I have attached the data set for your reference.
Looking forward to your help in this regard
With best regards,
Upananda

Respuesta aceptada

Star Strider
Star Strider el 7 de Oct. de 2021
Editada: Star Strider el 7 de Oct. de 2021
I would use the readtable function —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/760931/MCXCOMEX.xlsx', 'VariableNamingRule','preserve')
T1 = 874×4 table
date mcx comex spot ___________ ______ _____ _____ 07-Jan-2005 227.98 6.429 6.46 14-Jan-2005 233.36 6.58 6.63 21-Jan-2005 235.62 6.797 6.58 28-Jan-2005 235.71 6.808 6.77 04-Feb-2005 232.42 6.625 6.655 11-Feb-2005 242.51 7.201 6.98 18-Feb-2005 248.78 7.413 7.32 25-Feb-2005 246.94 7.291 7.243 04-Mar-2005 249.56 7.349 7.17 11-Mar-2005 255.36 7.535 7.415 18-Mar-2005 251.32 7.377 7.335 25-Mar-2005 240.76 6.933 7.32 01-Apr-2005 243.33 6.99 7.105 08-Apr-2005 245.62 7.161 7.03 15-Apr-2005 242.91 7.018 7.01 22-Apr-2005 247.47 7.271 7.235
Also see the documentation on table for information on how to use table arrays.
EDIT — (7 Oct 2021 at 15:16)
Retrieving the header information (variable names) is also straightforward —
VN = T1.Properties.VariableNames
VN = 1×4 cell array
{'date'} {'mcx'} {'comex'} {'spot'}
Access the contents of ‘VN’ as with any cell array.
.

Más respuestas (0)

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by