textscan to read date and time column and numeric data together

1 visualizzazione (ultimi 30 giorni)
dddd
Thank you Stephen23. I am attaching the file. The purpose is to read the file from row 66 to end. After that I want to Connect the columns of the read numbers horizontally. May be by using 'horzcat' command. Thank you
I am new to MatLAB. I want touse textscan command to read the data. the first column is date and time and rest are numeric. can anyone help me in this?
  1 Commento
Stephen23
Stephen23 il 1 Lug 2022
Modificato: Stephen23 il 1 Lug 2022
Try using READTABLE()
If you upload a sample file by clicking the paperclip button then someone can help you.

Accedi per commentare.

Risposta accettata

Stephen23
Stephen23 il 1 Lug 2022
T = readtable('WHP-SEA-TP116-HS417-S1.csv', 'NumHeaderLines',66)
T = 65629×7 table
Var1 Var2 Var3 Var4 Var5 Var6 Var7 ________________ _______ ______ ________ ________ _________ _______ 05/23/2022 11:57 0 2.8496 0.056305 0.019797 -0.03085 -0.1675 05/23/2022 11:57 10000 2.8496 0.056305 0.022843 -0.029307 0.169 05/23/2022 11:57 20000 2.8496 0.056305 0.025888 -0.029307 -0.1675 05/23/2022 11:57 30000 2.8494 0.056305 0.027411 -0.027765 0.1685 05/23/2022 11:57 40000 2.8494 0.054741 0.025888 -0.027765 -0.1665 05/23/2022 11:57 50000 2.8496 0.054741 0.024365 -0.026222 0.1675 05/23/2022 11:57 60000 2.8494 0.054741 0.025888 -0.027765 -0.1655 05/23/2022 11:57 70000 2.8494 0.056305 0.030457 -0.027765 0.1675 05/23/2022 11:57 80000 2.8496 0.054741 0.03198 -0.027765 -0.166 05/23/2022 11:57 90000 2.8496 0.056305 0.030457 -0.023138 0.1675 05/23/2022 11:57 1e+05 2.8496 0.053177 0.027411 -0.02468 -0.165 05/23/2022 11:57 1.1e+05 2.8496 0.054741 0.030457 -0.023138 0.1675 05/23/2022 11:57 1.2e+05 2.8496 0.054741 0.033502 -0.023138 -0.165 05/23/2022 11:57 1.3e+05 2.8496 0.056305 0.033502 -0.020053 0.167 05/23/2022 11:57 1.4e+05 2.8494 0.056305 0.03198 -0.021595 -0.1655 05/23/2022 11:57 1.5e+05 2.8496 0.054741 0.030457 -0.021595 0.1665

Più risposte (1)

Kshittiz Bhardwaj
Kshittiz Bhardwaj il 1 Lug 2022
Hello Sohail,
You have to first load open your file in MATLAB and then read each column with the appropriate conversion specifier.
You can refer : TextScan documentation
Personally, I would suggest you to use readTable instead of textScan as it is easier and straight forward

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by