textscan to read date and time column and numeric data together

조회 수: 4 (최근 30일)
Sohail Hasan
Sohail Hasan 2022년 7월 1일
댓글: Sohail Hasan 2022년 7월 1일
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
Stephen23
Stephen23 2022년 7월 1일
편집: Stephen23 2022년 7월 1일
Try using READTABLE()
If you upload a sample file by clicking the paperclip button then someone can help you.

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen23
Stephen23 2022년 7월 1일
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

추가 답변 (1개)

Kshittiz Bhardwaj
Kshittiz Bhardwaj 2022년 7월 1일
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

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by