How to read data from dat file and plot ?

92 次查看(过去 30 天)
Kathy
Kathy 2017-5-24
回答: 10B 2017-5-26
I want to read the data from the dat file. Skip first 5 lines and read after that. Finally I want to plot 3 columns from the data . Here is the sample data
"BBB5","BNOO_W2_KIOP_IP","CV1000","79598","TY1000.Ltd.29","CPU:tmid2.cr1","19501","KRS_Step" "TIMESTAMP","Data","SDF_Counter","_Mthu232","_WF232Drrt","Parms(1)","Parms(2)","Parms(3)","Parms(4)","Parms(5)","Parms(6)","Parms(7)","Parms(8)","Parms(9)","Parms(10)","Parms(11)","Parms(12)","Parms(13)" "LS","RTY","","","","","","","","","","","","","","","","" "","","KPp","KPp","KPp","KPp","KPp","KPp","KPp","KPp","KPp","KPp","KPp","KPp","KPp","KPp","KPp","KPp" "2017-05-19 10:55:08",2,1,1,3.107,15.414,153.65,3.107,3.1,6.96,295.88,0.58,1.1,0.12,107.86,10.78,6.43,12.28 "2017-05-19 10:55:08",2,1,1,3.107,15.414,153.65,3.107,3.1,6.96,295.88,0.58,1.1,0.12,107.86,10.78,6.43,12.28 "2017-05-19 10:55:08",2,1,1,3.107,15.414,153.65,3.107,3.1,6.96,295.88,0.58,1.1,0.12,107.86,10.78,6.43,12.28

回答(1 个)

10B
10B 2017-5-26
Hello Kathy,
I think you want to read this answer from Walter: https://uk.mathworks.com/matlabcentral/answers/79885-reading-dat-files-into-matlab which explains how to do it.
Then plotting should be straightforward. I would save the output data as variables, XY, then take a look at "doc plot", called by writing it in the worksapce.
Remember that Matlab works in order of row then column so if you wanted to plot the 6th row against all columns you would write plot(X(6,:)); or similar, depending on how your data was arranged as variables.
Hope that helps. Give it a try and see how you get on.
10B.

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by