Hi i need help in file conversion .txt to mat file

조회 수: 1 (최근 30일)
navya 2013년 5월 31일
I have some data collected on machine which is in .txt format. I want to convert it to a mat file. Here is what the data looks like
row1 Time 1_auto_mode 2_lift_target 3_ang_eve_mm 4_lift_command_per 5_LiftDir 6_CmdVel_mm_s 7_ACE_All_CtrlLaw_Switch 8_ACE_All_CtrlLaw_1_FL 9_ACE_All_CtrlLaw_2_L1AC 10_ACE_All_CtrlLaw_3_MRAC 11_ACE_All_CtrlLaw_4_PD 12_ACE_All_Target 13_ACE_All_BladeTipYDisp_RateTrasition 14_ACE_menu_target 15_ACE_mea_L1 16_ACE_mea_MRAC 17_ACE_lift_final_percent 18_lift_direct_final
row2 0.039991 0.000000 200000.000000 200380.000000 0.000000 0.000000 -3718.594742 4.000000 -3376.605662 -3538.103638 -7480609.559167 -3718.594742 200000.000000 200380.000000 10.000000 380.000000 380.000000 0.000000 0.000000
row3 0.059985 0.000000 200000.000000 200381.000000 0.000000 0.000000 -3743.363776 4.000000 -3508.938222 -3546.986694 -7493434.222546 -3743.363776 200000.000000 200381.000000 10.000000 381.000000 381.000000 0.000000 0.000000
similar fashion i have 2179 rows
can some one help me with this
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 6월 2일
You are going to have to specify what is header, what is text in a column, which columns are numeric, which columns to be ignored...
Are "row1" and "row2" literal, or do you mean that the first row is what follows there (the 19 fields), and the second row is the series of numbers that follow on that line? I do count 19 numeric values.

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

답변 (1개)

Amith Kamath
Amith Kamath 2013년 6월 2일
Although this may not be the best way to do this, but you can use IMPORTDATA to import all the data from the '.txt' file as a structure. This will save the text headers separately and the data separately. You can then save this structure as a '.mat' file. See: http://www.mathworks.com/help/matlab/ref/importdata.html


Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기


Community Treasure Hunt

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

Start Hunting!

Translated by