# Read multiple text files in MATLAB

Page 1 of 1

## 0 Replies - 363 Views - Last Post: 10 October 2015 - 09:34 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=382848&amp;s=3c6c56dd10ca680fb56ca9e66d746429&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Ameri

Reputation: 2
• Posts: 43
• Joined: 26-October 13

# Read multiple text files in MATLAB

Posted 10 October 2015 - 09:34 AM

Hi there,

I need to read "a specific number" (highlighted below) in 1998 different text files (text1.txt, text2.txt, ..., text1998.txt) simultaneously and print that numbers in another file (preferably, an excel file). All the files are a mixture of strings and numbers and look like as follows:

----------------------------------------------------------------------------------------------------
Structure: Biaxial House model with 1 story.

Maximum responses---------------------------
Displacements: X Y R
Story--1: 1.267323e+000 1.251265e-016 1.574376e-011

Maximum Inter-story responses---------------------------
Inter-story Drifts: dX dY dR
Story--1: 1.267323e+000 1.251265e-016 1.574376e-011

Maximum story forces---------------------------
Total force at story: Fx Fy Mr
Story--1: 6.152071e+003 1.364242e-012 4.009894e-003

Maximum story Accelerations---------------------------
Global Accel at story Centroid: Ax Ay Ar
Story--1: 3.860713e+001 9.869805e-017 3.364166e-010

The average acceleration is calculated using a 0.01sec time interval
Note: If the specified time interval is smaller than the time interval of input excitation, the excitation time interval is used to calculate the average Accel.
Maximum story Average Accelerations---------------------------
Global Accel at story Centroids:(average) Ax Ay Ar
Story--1: 8.247387e-001 9.865127e-017 2.810327e-010

Building Damage index calculated based on Hysteretic elements:
8.239350e-001
Local Maximum Results----------------
Shear elements results:

For story 1
Wall Max Drift Max Force Energy Dissipation Damage index
St1W1: 1.267323e+000 3.076035e+003 8.260148e+003 8.239350e-001
St1W2: 5.667753e-010 4.107950e-006 2.013470e-016 1.686831e-010
St1W3: 1.267323e+000 3.076035e+003 8.260148e+003 8.239350e-001
St1W4: 5.667754e-010 4.107949e-006 2.013477e-016 1.686832e-010

----------------------------------------------------------------------------------------------------

I really don't know how to do that (I know how to read a simple excel file, or how to read a *.txt file that only contains numbers, but really got into trouble with reading that specific number in a mixed file, and also don't know how to use a 'for' loop that reads all the 1998 files for me!). So, could any of you do me a favor and help me with this please (a sample file is also attached below. Please note that the suffix is *.gen but I use notepad to read these files)?!

Thanks a lot

This post has been edited by Ameri: 10 October 2015 - 09:38 AM

Is This A Good Question/Topic? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }