How to import data from specific rows of text file

7 Ansichten (letzte 30 Tage)
sreenivas
sreenivas am 16 Jul. 2017
Beantwortet: Image Analyst am 16 Jul. 2017
Hi.. I have file of this type. I want to pick up the data between TRACE OF GIVEN PAIRS OF BODIES and RELATIVE DISTANCE BETWEEN TWO BODIES. Text file contains following things.
TIME : 0.7740000E-01
----------------------
ONE : 1st Body
-----
FORCES AND MOMENTS
TOTAL : 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
PSEUDO FORCES : -0.707771E-02 0.537278E+01 0.662794E+01 0.121569E-01 0.491797E-04 0.446283E-04
BUTTING IS NOT ACTIVE
POSITION AND VELOCITY : 1.479498 0.3043175 -0.7346008 0.9821817 0.8449973E-03 0.3638550E-03
ATTITUDE AND ATTITUDE RATE : -0.3176537E-04 0.2367561E-01 -0.1919213E-01 -0.9175004E-03 0.8578123 -0.6953668
MASS AND INERTIA : 450.7300 107.1000 0.000000 0.000000 0.000000 293.2474
: 0.000000 0.000000 0.000000 360.1526
VELOCITY IN LI : 0.9821820 0.5160000E-03 -0.4200000E-04
ACCELERATION : -0.1570277E-04 0.1192018E-01 0.1470489E-01 0.6503610E-02 0.9608914E-05 0.7099801E-05
SENSED ACCELERATION : -0.1570277E-04 0.1192018E-01 0.1470489E-01 0.6503610E-02 0.9608914E-05 0.7099801E-05
TWO : 2nd Body
-----
FORCES AND MOMENTS
TOTAL : 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
PSEUDO FORCES : 0.826370E-01 0.885848E+01 -0.262976E+02 -0.251807E+01 -0.642482E+01 0.143961E+02
BUTTING IS NOT ACTIVE
POSITION AND VELOCITY : -0.3500549 -0.7199725E-01 0.1738017 -0.2323872 0.2199652E-03 -0.6561520E-03
ATTITUDE AND ATTITUDE RATE : -0.5985070E-01 0.9403061E-01 0.3138108E-01 -2.169675 3.405598 1.140376
MASS AND INERTIA : 1905.000 1381.000 -1066.000 562.0000 -1066.000 7036.000
: -126.0000 562.0000 -126.0000 7082.000
VELOCITY IN LI : -0.2323880 0.9200000E-04 -0.2750000E-03
ACCELE : 0.4337898E-04 0.4650122E-02 -0.1380451E-01 -0.1729076E-01 -0.5177675E-01 0.1160182
SENSED ACCELE : 0.4337898E-04 0.4650122E-02 -0.1380451E-01 -0.1729076E-01 -0.5177675E-01 0.1160182
TRACE OF GIVEN PAIRS OF BODIES
------------------------------
NO PX1 PX2 DX3 DISTANCE X1 X2 Y1 Y2 Z1 Z2 LAT DIST XLAMB
-- --- --- --- -------- -- -- -- -- -- -- -------- ------
1 2.328 -0.2301 0.1703 2.345 0.3644 2.692 -0.2671E-01-0.2569 -0.3141 -0.1438 0.2863 1.000
2 1.734 0.9399E-01 0.2614 1.756 0.3646 2.098 0.5894 0.6834 -0.2493 0.1210E-01 0.2778 1.000
----------------------------------------------------------------------------------------------------------------------------------
RELATIVE DISTANCE BETWEEN TWO BODIES
-------------------------------------

Antworten (1)

Image Analyst
Image Analyst am 16 Jul. 2017
Make it easy for people to help you by attaching your file with the paper clip icon. You might have to do down line by line with fgetl() and contains() until you find the rows you want, then use sscanf() or textscan() to extract the numbers.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by