how to get data from a .txt file
    조회 수: 6 (최근 30일)
  
       이전 댓글 표시
    
how to get data from a .txt file.I need numerical data only after 'Init seq' to perform calculations in matlab and create a .txt file with new data same as the source file.
   ------------------ Header -------------------------------------
TestDescription  
DateTime  06.02.2013;11:50:17
SensorType  COMBO1.5 SENSOR
FrameType  OFFFRAME
CPOL  0
CPHA  0
Sensor  2
SensorRS485  
SensorArmingPinX  
SensorArmingPinY  
SensorPullResistor  
AD  1;2;3;4
Digital  
SensorVcc  3.30 V
BurstRate  2000 Hz
MOSICount_Burst  20
SPIRate  40000 Hz
SCLK  8000000 Hz
ToolVersion  
FPGAVersion  SC 0.10
DeviceName  USB <-> SPICE  SN: 00009
ProjectFilename  Project_Combo1.5.spi-cfg
CommandFilename  Bosch_COMBO_1_5_SPI_Commands_and_Replies.h
CommandFileRevision  1.22
CRCTableFilename  Bosch_COMBO_1_5_SPI_CRC_Table.c
CRCTableFileRevision  1.4
HW-State;Time[ms];MOSI[hex];MISO2[hex];MISO2-State;AIn1[mV];AIn2[mV];AIn3[mV];AIn4[mV];
------------------ Init Sequence ------------------------------
80;0.000;402B01E8;FFFFFFFF;00; 10;122;1993;1994;
80;0.025;802B00FB;FFFFFFFF;05; 11;123;1995;1996;
80;0.050;806000FE;FFFFFFFF;05; 11;122;1995;1996;
80;0.075;803E00E2;FFFFFFFF;05; 10;121;1993;1994;
80;0.100;803E00E2;FFFFFFFF;00; 11;124;1996;1998;
80;0.125;80500091;FFFFFFFF;00; 10;121;1993;1995;
80;0.150;80510078;FFFFFFFF;05; 10;122;1993;1995;
80;0.175;8052006C;FFFFFFFF;05; 12;123;1995;1997;
80;0.200;80530085;FFFFFFFF;05; 10;122;1993;1994;
80;0.225;80540044;FFFFFFFF;05; 12;123;1995;1997;
80;0.250;805500AD;FFFFFFFF;05; 10;122;1995;1996;
80;0.275;805600B9;FFFFFFFF;05; 10;121;1992;1993;
80;0.300;80570050;FFFFFFFF;05; 11;123;1996;1998;
80;0.325;80580014;FFFFFFFF;05; 10;122;1993;1995;
80;0.350;805900FD;FFFFFFFF;05; 10;122;1994;1995;
80;0.375;805A00E9;FFFFFFFF;05; 12;123;1996;1997;
80;0.400;40290115;FFFFFFFF;05; 10;121;1993;1994;
80;0.425;20000002;FFFFFFFF;05; 11;123;1996;1997;
80;0.450;600000F3;FFFFFFFF;05; 10;122;1995;1995;
80;0.475;A00000CF;FFFFFFFF;05; 10;122;1993;1994;
80;0.500;802F002E;FFFFFFFF;05; 11;123;1996;1998;
80;0.525;803100A6;FFFFFFFF;05; 10;122;1993;1995;
80;0.550;8033005B;FFFFFFFF;05; 11;123;1995;1996;
80;0.575;40290115;FFFFFFFF;05; 11;122;1995;1996;
80;0.600;20000002;FFFFFFFF;05; 10;122;1993;1993;
80;0.625;600000F3;FFFFFFFF;05; 11;123;1996;1998;
80;0.650;A00000CF;FFFFFFFF;05; 10;122;1993;1995;
80;0.675;802F002E;FFFFFFFF;05; 10;122;1993;1994;
80;0.700;803100A6;FFFFFFFF;05; 12;123;1996;1997;
80;0.725;8033005B;FFFFFFFF;05; 10;122;1993;1994;
80;0.750;40290115;FFFFFFFF;05; 10;123;1995;1997;
80;0.775;20000002;FFFFFFFF;05; 11;122;1994;1996;
80;0.800;600000F3;FFFFFFFF;05; 10;121;1992;1994;
80;0.825;A00000CF;FFFFFFFF;05; 12;124;1997;1998;
80;0.850;802F002E;FFFFFFFF;05; 10;122;1993;1995;
80;0.875;803100A6;FFFFFFFF;05; 10;122;1994;1995;
댓글 수: 0
채택된 답변
  Charles David
 2013년 2월 14일
        use textscan command and since you do not need the initail lines use the 'HeaderLines' option(in that you can specify how many lines u want to skip) use this: first open the file with fopen assume file identifier used is fid then, C=textscan(fid,'%d%f%s%s%d%d%d%d%d','Delimeter',';','HeaderLines','30');
댓글 수: 2
  Stephen23
      
      
 2015년 5월 8일
				The header lines values needs to be a numeric instead of a string:
textscan(fid,... 'HeaderLines',30)
추가 답변 (2개)
  the cyclist
      
      
 2013년 2월 14일
        
      편집: the cyclist
      
      
 2013년 2월 14일
  
      If you have a relatively new version of MATLAB (2012b or newer, I think), there is an "Import Data" tool in Home tab of the command window. Via a GUI, you can select the data to import. MATLAB will also generate code for you to do this programmatically.
  Saif Awwad
 2015년 5월 8일
        Do you need to achieve this exclusively by using MATLAB? This is a relatively easy task if using SHELL or PERL languages.
댓글 수: 1
  Walter Roberson
      
      
 2015년 5월 8일
				Stephen, I removed your flag. The Answer discusses the possibility of using an additional tool to preprocess the data, which is a fair response. In particular, calling perl is built-in to MATLAB, see here so suggesting using a MATLAB invocation of Perl is definitely in-bounds for the Answers forum.
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





