Extracting text files to Matlab

I have text files that look like:
File Path: C:\Users\Administrator\Desktop\Zach\Mortar Cube\7-Day Compression\Moist 7-day Cube_Sample 1 7-13-2018 11 12 45 AM\DAQ- Running Time, … - (Timed).txt
Test: ASTM C109_Mortar Cube Compression Test
Test Run: Moist 7-day Cube_Sample 1
Date: 7/13/2018 11:02:53 AM
Running Time Axial Displacement Axial Force
sec mm kN
0 0.000253692263640914 -0.00141541242599487
0.060546875 0.000561960064260347 0.00422510766983032
0.16015625 -0.0128228221001336 -0.027672025680542
0.259765625 -0.0297963615594199 -0.130675277709961
0.359375 -0.0440802432422061 -0.270625793457031
0.458984375 -0.0536819934495725 -0.421226684570312
0.55859375 -0.0646775588393211 -0.599325500488281
0.658203125 -0.0716587528586388 -0.753527221679688
0.7578125 -0.0759070753701963 -0.863487121582031
with the data continuing. I want to extract it so that it makes an array of just the data.

Answers (1)

There are several ways to read your file.
One option, using the textscan (link) function:
fidi = fopen('filename.txt','rt');
D = textscan(fidi, '%f%f%f', 'HeaderLines',8, 'CollectOutput',1);
fclose(fidi);
You may need other name-value pair arguments as well.
The detectImportOptions (link) function is frequently useful to help you decide how best to import your files.

Categories

Tags

Asked:

on 15 Jan 2019

Answered:

on 15 Jan 2019

Community Treasure Hunt

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

Start Hunting!